<template>
  <div class="basic_info">
    <div class="info_operation_btn">
      <div class="btn_left">
        <el-tooltip effect="dark" content="快捷键 Alt + N" :enterable="false" placement="bottom-start">
          <el-button type='primary' @click="onNewOrder">新单(N)</el-button>
        </el-tooltip>

        <el-tooltip effect="dark" content="快捷键 Alt + S" :enterable="false" placement="bottom-start">
          <el-button v-if="buttonsPermissions.LuRu" @click="onSubmit" :disabled="orderStatus == 10"
            accesskey="s">保存(S)</el-button>
          <!-- <el-button v-else class="disabled_button" disabled>保存(S)</el-button> -->
        </el-tooltip>
        <!-- :disabled="auditBtnStatus" -->
          <!-- v-if="buttonsPermissions.Zuofei"  -->
          <el-button 
            :disabled="orderStatus == 66||orderStatus == 10"
            :class="orderStatus == 66||orderStatus == 10 ? 'disabled_button' : ''"
            @click="cancellation"  :loading="examineLoading">作废</el-button>
          <!-- <el-button v-else class="disabled_button" disabled>作废</el-button> -->

        <!-- <el-select v-model="importValue">
          <el-option
            v-if="buttonsPermissions.DaoRu"
            :disabled="orderStatus != 66 && orderStatus != 0"
            label="导入"
            value="导入"
            @click.native="importExcel"
            :style="orderStatus != 66 && orderStatus != 0 ? 'pointer-events: none' : ''"
          ></el-option>
          <el-option v-else disabled label="导入" value="导入" style="pointer-events: none"></el-option>
          <el-option
            v-if="buttonsPermissions.DaoChu"
            :disabled="orderStatus == 66"
            label="导出"
            value="导出"
            @click.native="exportExcel()"
            :style="orderStatus == 66 ? 'pointer-events: none' : ''"
          ></el-option>
          <el-option v-else disabled label="导出" value="导出" style="pointer-events: none"></el-option>
        </el-select> -->
        <el-button v-if="buttonsPermissions.DaoChu" :disabled="orderStatus == 66"
        :class="orderStatus == 66 ? 'disabled_button' : ''" @click="exportExcel()">导出</el-button>
        <!-- 打印 -->
        <el-tooltip effect="dark" content="快捷键 Alt + P" :enterable="false" placement="bottom-start">
          <el-button v-if="buttonsPermissions.DaYin" :disabled="orderStatus == 66"
            :class="orderStatus == 66 ? 'disabled_button' : ''" @click="handleShortcutKeyPrint">打印(P)</el-button>
          <el-button v-else class="disabled_button" disabled>打印</el-button>
        </el-tooltip>

        <!-- <el-button @click="onShare" v-if="buttonsPermissions.FenXiang">分享</el-button>
        <el-button v-else class="disabled_button" disabled>分享</el-button> -->
        <img v-if="orderStatus == 5" style="width: 50px; height: 38px; margin-right: 10px;" src="@/assets/shenhe.png" />
        <img v-else-if="orderStatus == 10" style="width: 57px; height: 43px; margin-right: 10px;"
          src="@/assets/zuofei.png" />
        <img v-else-if="orderStatus == 20" style="width: 57px; height: 24px; margin-right: 10px;"
          src="@/assets/hongchong.png" />
        <!-- <span v-else style="color: #1993fb; margin-right: 10px">{{ queryData.orderState_dictText || '未保存' }}</span> -->
        <img v-if="queryData.performState == 1" style="width: 46px; height: 29px; margin-right: 10px;"
          src="@/assets/wancheng.png" />
        <div style="width: 75px; display: flex; justify-content: space-between;margin-left: 20px;">
          <el-tooltip effect="dark" content="上一条" :enterable="false" placement="top">
            <el-button @click="onUpper" class="arrow_btn" icon="el-icon-arrow-left" :loading="upperLoading"></el-button>
          </el-tooltip>
          <el-tooltip effect="dark" content="下一条" :enterable="false" placement="top">
            <el-button @click="onLower" class="arrow_btn" icon="el-icon-arrow-right" :loading="lowerLoading"></el-button>
          </el-tooltip>
        </div>
      </div>
    </div>
    <div class="info_content_div">
      <div class="div_table">
        <div class="div_screen">
          <div class="custom_left bill_mask_back_view">
            <!-- v-if="maskViewStatus" -->
            <div v-if="invoiceStatus == 1" class="bill_mask_view"></div>

            <!-- 供应商 -->
            <div class="custom_item">
              <div class="custom_star">
                <div class="custom_label" style="width: auto;min-width: 40px">供应商</div>
                <span class="star">*</span>
              </div>
              <div class="custom_select_head">
                <el-tooltip :disabled="xghCompany.length <= 6" effect="dark" :content="xghCompany" :enterable="false"
                  placement="bottom-start">
                  <el-select v-model="queryData.xghCompanyId" style="width: 100%" filterable ref="deptSelect"
                    @visible-change="(value) => handleFilterMethod('', 'companyName')"
                    :filter-method="(value) => handleFilterMethod(value, 'companyName')" @change="onClickCompany">
                    <el-option v-for="item in gysOptions" :key="item.id" :label="item.companyName"
                      :value="item.id" :disabled="item.status == '1'"></el-option>
                    <el-option v-if="companyAdd" key label value>
                      <div class="custom_add" @click.stop="onShowSupplierAdd">
                        <i class="el-icon-plus"></i>
                        <span>新增</span>
                      </div>
                    </el-option>
                  </el-select>
                </el-tooltip>
                <div class="custom_more">
                  <i class="el-icon-more"  @click.stop="onShowSupplier"></i>
                </div>
                <!-- <img @click="onShowSupplierEdit"src="@/assets/img/edit_icon.png" style="width: 16px;height: 16px;cursor: pointer"></img> -->
              </div>
            </div>
            <!-- 经手人 -->
            <div class="custom_item">
              <div class="custom_star">
                <div class="custom_label" style="width: auto;min-width: 40px">经手人</div>
              </div>
              <div class="custom_select_head">
                <el-select v-model="queryData.sysUserId" style="width: 100%" filterable ref="deptSelect"
                  @visible-change="(value) => handleFilterMethod('', 'realname')"
                  :filter-method="(value) => handleFilterMethod(value, 'realname')">
                  <el-option v-for="item in jsrOptions" :key="item.id" :label="item.realname"
                    :value="item.id"></el-option>
                  <el-option key label value>
                    <div class="custom_add" @click.stop="onShowStaffAdd">
                      <i class="el-icon-plus"></i>
                      <span>新增</span>
                    </div>
                  </el-option>
                </el-select>
              </div>
            </div>
            <!-- 部门 -->
            <div class="custom_item">
              <div class="custom_star">
                <span class="custom_label" style="width: auto;min-width: 50px">部门</span>
              </div>
              <div class="custom_select_head">
                  <el-select
                    v-model="queryData.departId"
                    style="width:100%;"
                    filterable
                    ref="deptSelect"
                    :filter-method="filterMethodByDept"
                    @visible-change="visibleChange"
                  >
                    <el-option
                      v-for="item in deptOptions"
                      :key="item.id"
                      :label="item.deptName"
                      :value="item.id"
                    ></el-option>
                    <!-- <el-option key label value>
                      <div class="custom_add" @click.stop="onAddDeptTree">
                        <i class="el-icon-plus"></i>
                        <span>新增</span>
                      </div>
                    </el-option> -->
                  </el-select>
                  <!-- <div class="custom_more">
                    <i class="el-icon-more" @click.stop="onShowTreeByDept"></i>
                  </div> -->
                </div>
            </div>
            <!-- 开票日期 -->
            <div class="custom_item">
              <div class="custom_star">
                <div class="custom_label" style="width: auto;min-width: 50px">开票日期</div>
              </div>
              <div class="custom_select_head">
                <el-date-picker v-model="queryData.invoiceTime"
                  value-format="yyyy-MM-dd" style="height: 30px"></el-date-picker>
              </div>
            </div>
            <!-- 发票号码 -->
            <div class="custom_item">
              <div class="custom_star">
                <div class="custom_label" style="width: auto;min-width: 50px">发票号码</div>
              </div>
              <div class="custom_select_head">
                <el-tooltip
                effect="dark"
                :content="queryData.invoiceNumber"
                :enterable="false"
                placement="bottom-start"
                :disabled="queryData.invoiceNumber.length <= 6"
              >
                <div class="custom_select_head">
                  <el-input type="text" v-model="queryData.invoiceNumber" placeholder="请输入" />
                </div>
              </el-tooltip>
              </div>
            </div>
            <!-- 发票类型 -->
            <div class="custom_item">
              <div class="custom_star">
                <div class="custom_label" style="width: auto;min-width: 50px">发票类型</div>
                <span class="star">*</span>
              </div>
              <div class="custom_select_head">
                <el-select v-model="queryData.invoiceType" style="width: 100%" filterable  placeholder="请选择" :filter-method="handleFilterInvoiceType"
                @visible-change="visibleChangeFp">
                  <el-option
                    v-for="item in fpOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </div>
            </div>
            <!-- 开票金额 -->
            <div class="custom_item">
              <div class="custom_star">
                <div class="custom_label" style="width: auto;min-width: 50px">开票金额</div>
                <span class="star">*</span>
              </div>
              <div class="custom_select_head">
                <!-- <el-tooltip
                effect="dark"
                :content="queryData.invoicePrice"
                :enterable="false"
                placement="bottom-start"
                :disabled="queryData.invoicePrice.length <= 6"
              > -->
                <div class="custom_select_head">
                  <el-input type="text" v-model="queryData.invoicePrice" placeholder="请输入" />
                </div>
              <!-- </el-tooltip> -->
              </div>
            </div>
            <!-- 开票方式 -->
            <div class="custom_item">
              <div class="custom_star">
                <div class="custom_label" style="width: auto;min-width: 50px">开票方式</div>
                <span class="star">*</span>
              </div>
              <div class="custom_select_head">
                <el-select v-model="queryData.invoiceWay" @change="handleMethodChange()" :filter-method="handleFilterInvoiceWay"
                @visible-change="visibleChangeKp" style="width: 100%" filterable placeholder="请选择">
                  <el-option
                    v-for="item in kpOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </div>
            </div>
          </div>
          <!-- <div class="screen_right">
            <i @click="onShowColumn()" class="set_up el-icon-s-tools" :size="20"></i>
          </div> -->
        </div>
        <!-- <extendedFields ref="extendedFieldsRef" :disabled="maskViewStatus"></extendedFields> -->
        <div style="height: 60px;">
          <div class="bill_mask_back_view">
            <!-- v-if="maskViewStatus" -->
            <div v-if="invoiceStatus == 1" class="bill_mask_view"></div>
         <div class="custom_line" style="display: flex;align-items: center;margin: 20px 0;">
          <div style="color: #1B94FB;">发票数据</div>
          <div style="margin-left: 30px;">不含税金额：{{ queryData.price }}</div>
          <!-- <div style="margin-left: 60px;">税 额：0.00</div> -->
          <div v-if="queryData.invoiceWay !== '0'" class="custom_item" style="margin-left: 60px;">
              <div class="custom_star">
                <div class="custom_label" style="width: auto;min-width: 50px">税 额</div>
              </div>
              <div class="custom_select_head">
                <div class="custom_select_head">
                  <el-input type="text" v-model="queryData.taxAmount" placeholder="请输入" />
                </div>
              </div>
            </div>
          <div v-else style="margin-left: 90px;">税 额：{{ queryData.taxAmount }}</div>
          <div v-if="queryData.invoiceWay == '2'" class="custom_item" style="margin-left: 60px;">
              <div class="custom_star">
                <div class="custom_label" style="width: auto;min-width: 50px">价税合计</div>
              </div>
              <div class="custom_select_head">
                <div class="custom_select_head">
                  <el-input type="text" v-model="queryData.priceTaxTotal" placeholder="请输入" />
                </div>
              </div>
            </div>
          <div v-else style="margin-left: 90px;">价税合计：{{ queryData.priceTaxTotal }}</div>
         </div>
        </div>
      </div>


         <div style="display: flex;align-items: center;justify-content: space-between;">
            <div>发票明细：</div>
            <div style="display: flex;align-items: center;">
              <el-button :disabled="invoiceStatus == 1" v-show="queryData.invoiceWay !== '2'" class="chaoZuoBtn" @click="getAuto">自动分配</el-button>
              <el-button :disabled="invoiceStatus == 1" v-show="queryData.invoiceWay !== '2'" class="chaoZuoBtn" type="primary" @click="getAdd">添加</el-button>
              <el-button :disabled="invoiceStatus == 1" v-show="queryData.invoiceWay !== '2'" class="chaoZuoBtn" style="color: red;" @click="getDel">删除</el-button>
              <i @click="onShowColumn()" class="set_up el-icon-s-tools" :size="20" style="margin-left: 20px;"></i>
            </div>
          </div>
        <div class="table_content">
          <div>
            <NewTable ref="newTableRef" :TableConfig="TableConfig" orderName="销项发票信息"
              billName="销项发票信息" :billDisabled="this.queryData.invoiceWay == '2' || invoiceStatus == 1" :companyId="queryData.xghCompanyId"
              :storehouseId="queryData.xghStorehouseId" :discountRate="queryData.orderRebate" :taxRate="taxRate"
               @onHandleAllPrice="onHandleAllPrice" @onHandleDrag="onDragColumn" @onUpdateColumn="onUpdateColumn">
            </NewTable>
            <!-- @onHandleSpData="onHandleSpData" @onHandleUnit="onHandleUnit" -->
          </div>
        </div>
      </div>
    </div>
    <DialogInvoice ref="dialogInvoice" @onSelectBill="transferBillCallback"></DialogInvoice>
    <!-- 列配置弹框       :columnDatasObj="TableConfig.columnData"-->
    <CConfiguration ref="setColumnRef" :columnDataArr="getColumnList" :defaultColumnDataArr="defaultColumnData"
      :orderType="pageName" @onSaveColumn="onSaveColumn"></CConfiguration>
    <!-- 选择供应商弹框 -->
    <DialogSupplier ref="supplierRef" @onSelectSupplier="onSelectSupplier"></DialogSupplier>
    <!-- 新增供应商弹框 -->
    <DialogSupplierAdd ref="supplierAddRef" :newData="newData" @dialogVisibleClose="onCloseAddSupplier"
      @onAddSubmit="onAddSupplier"></DialogSupplierAdd>
    <DialogTree ref="treeRef" @onSelectTree="onSelectTree"></DialogTree>
    <!-- 新增员工弹框 -->
    <DialogStaffAdd ref="staffAddRef" @dialogVisibleClose="onCloseAddStaff" @onAddSubmit="onAddStaff"></DialogStaffAdd>
    <!-- 提醒弹框 -->
    <PopupReminder ref="reminderRef" :tipsData="tipsData" @onConfirm="onYes" @onCancel="onCancel"></PopupReminder>
    <!-- 成功弹框 -->
    <PopupSuccess ref="successRef" :tipsData="tipsData" @onConfirm="onOptionSuccess"></PopupSuccess>
    <!-- 操作日志 -->
    <DialogOperationLog :logTitle="logTitle" ref="operationLogRef"></DialogOperationLog>
    <!-- 导入 -->
    <DialogImport ref="daoru" :titles="TableConfig.columnData" :storehouseId="queryData.xghStorehouseId"
      url="/xghInvoiceInfo/xghInvoiceInfo/importExcel" @importData="importData" @downloadTemplate="exportExcel">
    </DialogImport>
    <dialogSimplePrompt ref="simplePrompt" @onSure="hongchongSure"></dialogSimplePrompt>
    <!-- 打印 -->
    <dialog-print ref="print"></dialog-print>
    <dialog-share ref="share"></dialog-share>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import DialogInvoice from '../../components/dialogInvoice'
import DialogTree from '../../components/dialogTree'
import dialogSimplePrompt from '../../components/dialogSimplePrompt'
import CConfiguration from '@/components/c_column/columnConfiguration1'
import DialogCommodity from '../../components/dialogCommodity'
import DialogSupplier from '../../components/dialogSupplier'
import DialogSupplierAdd from '../../components/dialogSupplierAdd'
import DialogStaffAdd from '../../components/dialogStaffAdd'
import PopupReminder from '../../components/popupReminder'
import PopupSuccess from '../../components/popupSuccess'
import DialogOperationLog from '../../components/dialogOperationLog'
import PopupDeApproval from '../../components/popupDeApproval'
import NewTable from '@/components/c_table/newTable'
import DialogImport from '@/components/c_Import/index1'
/**打印 */
import dialogPrint from '../../components/dialogPrint.vue'
import dialogShare from '../../components/dialogShare.vue'
import { getAction, postAction, putAction, downPostFile } from '@/api/manage'
import { ACCESS_TOKEN, TENANT_ID, ACCOUNT_BOOK } from '@/store/mutation-types'

import Vue from 'vue'
// 导入调用处理权限数据方法
import {
  handlePermissions,
  handleOtherPerms,
  sysConfig,
  handleOtherPermissions,
  getSystemParamsByName,
  formatFour,
  formatMoney,
  formatPrice,
  formatNumber,
  delcommafy,
  handleArrayToObject,
  handleObjectToArray,
  formatHundredMillionPrice,
  getPrintCompanyInfo,
  accSub, accAdd, accMul
} from '@/utils/index'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
export default {
  name: 'outgoingInfo',
  components: {
    DialogInvoice,
    DialogTree,
    CConfiguration,
    DialogCommodity,
    DialogSupplier,
    DialogSupplierAdd,
    DialogStaffAdd,
    PopupReminder,
    PopupSuccess,
    DialogOperationLog,
    PopupDeApproval,
    NewTable,
    DialogImport,
    dialogSimplePrompt,
    dialogPrint,
    dialogShare,
  },
  mixins: [JeecgListMixin],
  computed: {
    ...mapGetters(['isSupplementOrder']),
    auditBtnStatus() {
      return (
        this.orderStatus == 66 ||
        this.orderStatus == 5 ||
        this.orderStatus == 10 ||
        this.orderStatus == 20 ||
        this.orderStatus == 25 ||
        this.orderStatus == 30
      )
    },
    maskViewStatus() {
      return this.orderStatus != 66 && this.orderStatus != 0
    },
    getColumnList() {
      return handleObjectToArray(this.TableConfig.columnData)
    },
    formatPurchaseOrderPrice() {
      console.log('合计金额-----', this.queryData.purchaseOrderPrice)
      return formatHundredMillionPrice(delcommafy(this.queryData.purchaseOrderPrice))
    },
    formatArrearsPrice() {
      return formatHundredMillionPrice(this.queryData.arrearsPrice)
    },
    formatCreateOrderDate() {
      let date = this.queryData.createOrderDate
      if (date.length > 10) {
        date = date.slice(0, 10)
      }
      return date
    },
    buttonsPermissions() {
      return handlePermissions('销售订单')
    },
    companyAdd() {
      return handlePermissions('往来单位').LuRu
    },
    supplementPermissions() {
      return handleOtherPerms('补录单据')
    },
    printPermissions() {
      return handleOtherPerms('单据可多次打印')
    },
    /**销售价格低于成本价预警 */
    isBelowCost() { return sysConfig().sell_below_cost_alarm },
    /**单据保存后立即开新单 */
    isSaveNewOrder() { return sysConfig().open_new_order_after_document_saved },
    /**单据保存后立即审核 */
    isSaveExamine() { return sysConfig().verify_order_after_document_saved },
    /**单据审核后立即开新单 */
    isExamineNewOrder() { return sysConfig().open_new_order_after_document_verify },
    // 2、启用价格跟踪
    PriceTracking() { return sysConfig().enable_price_tracking },
    // 3、启用折扣率跟踪
    discountTracking() { return sysConfig().enable_discount_tracking },
    // 保存时单价为0不提示
    isInputSkip() { return sysConfig().unit_price_zero_no_prompt },
  },
  data() {
    return {
      pageName: '销项发票信息',
      form: {},
      invoiceStatus: 0, // 发票状态 0正常1作废
      // 部门
      deptOptions: [],
      fpOptions:[
        {
          id: '1',
          label: '普通发票',
          value: '1',
        },
        {
          id: '2',
          label: '增值税发票',
          value: '2',
        },
      ],
      kpOptions:[
        {
          id: '0',
          label: '按商品',
          value: '0',
        },
        {
          id: '1',
          label: '按单据',
          value: '1',
        },
        {
          id: '2',
          label: '不标记明细',
          value: '2',
        },
      ],
      accountBookId: '',
      invoiceId: '', //当前单据id
      // 存储按钮权限数据
      // buttonsPermissions: {},
      // supplementPermissions: false,
      // printPermissions: false,
      // storeAdd: false, // 仓库新增权限
      // companyAdd: false, // 往来单位权限
      // 传递给操作日志的值
      logData: {
        // orderId: 2,
        // orderType: '销售订单',
      },
      examineLoading: false,
      logTitle: '',
      // 传递给弹框的数据
      tipsData: {
        tipsWords: '',
        tipsMark: '',
        resultType: -1, //1、保存或编辑成功 2、审核成功
      },
      importValue: '导入',
      // 供应商
      gysOptions: [],
      
      // 经手人
      jsrOptions: [],
      // 税率
      taxRate: 0,
      // 新增仓库数据
      newWhData: {},
      // 新增经手人数据
      newStaffData: {},
      xghCompany: '', //客户
      // 查询条件数据
      queryData: {
        type: 1,
        id: '', //id
        xghCompanyId: '', //客户id
        sysUserId: '', //经手人id
        departId: '', //部门id
        invoiceTime: '', //开票日期
        invoiceNumber: '', // 发票号码
        invoiceType: '1', // 发票类型
        invoicePrice: 0, // 开票金额
        invoiceWay: '0', //开票方式
        // taxAmount: '0.00',//税额
        price: 0,  // 不含税金额
        taxAmount: 0,     // 税额
        priceTaxTotal: 0  // 价税合计
      },
      currentPage: 1, //默认开始页面
      showLiepeizhi: false, //是否显示列配置
      scanCode: '',
      orderFlag: 0, //先点上一单传1，先点下一单传2，点新单重置
      newData: {}, // 新增供应商数据
      // 按商品表头
      byCommoditycolumnData: {
          idx: {
            isShow: true,
            cellWidth: '70px',
            morenName: '序号',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'idx',
          },
          orderTime: {  
            isShow: true, 
            showLength: true,
            cellWidth: '150px',
            morenName: '单据日期',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            // noModify: true,
            props: 'orderTime',  
          },
          orderNumber: {  
            isShow: true,
            cellWidth: '150px',
            morenName: '单据编号',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            // noModify: false,
            props: 'orderNumber',  
          },
          goodsNumber: {
            isShow: true,
            cellWidth: '150px',
            morenName: '商品编码',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            // noModify: true,
            props: 'goodsNumber',
          },
          goodsName: {  
            isShow: true,
            cellWidth: '150px',
            morenName: '商品名称',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            // noModify: true,
            props: 'goodsName',  
          },
          goodsCode: {  
            isShow: true,
            cellWidth: '150px',
            morenName: '商品条码',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            // noModify: true,
            props: 'goodsCode',  
          },
          goodsNorms: {
            isShow: true,
            cellWidth: '100px',
            morenName: '规格',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'goodsNorms',
          },
          goodsUnit: {
            isShow: true,
            cellWidth: '100px',
            morenName: '单位',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'goodsUnit',
          },
          numberShow: {
            isShow: true,
            isSum: true,
            sumValue: 0,
            cellWidth: '100px',
            morenName: '数量',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'numberShow',
          },
          discountedUnitPrice: {  
            isShow: true,
            isSum: true,
            sumValue: 0,
            cellWidth: '100px',
            morenName: '折扣单价',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'discountedUnitPrice',  
          },
          discountAmount: { 
            isShow: true,
            isSum: true,
            sumValue: 0,
            cellWidth: '100px',
            morenName: '折扣金额',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'discountAmount', 
          },
          taxRate: {
            isShow: true,
            cellWidth: '100px',
            morenName: '税率%',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'taxRate',
          },
          taxAmount: {  
            isShow: true,
            isSum: true,
            sumValue: 0,
            cellWidth: '100px',
            morenName: '税额',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'taxAmount',  
          },
          invoicedOrderAmount: { 
            isShow: true,
            isSum: true,
            sumValue: 0,
            cellWidth: '100px',
            morenName: '已开票金额',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'invoicedOrderAmount',  
          },
          invoicableOrderAmount: {  
            isShow: true,
            isSum: true,
            sumValue: 0,
            cellWidth: '100px',
            morenName: '可开票金额',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'invoicableOrderAmount',  
          },
          nowInvoiceAmount: { 
            isShow: true,
            isSum: true,
            sumValue: 0,
            showType: 'input',
            cellWidth: '100px',
            morenName: '本次开票金额',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'nowInvoiceAmount',  
          },
          remark: {
            isShow: true,
            showType: 'input',
            cellWidth: '100px',
            morenName: '备注',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'remark',
          },
        },
        // 按单据表头
        byBillcolumnData: {
          idx: {
            isShow: true,
            cellWidth: '70px',
            morenName: '序号',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'idx',
          },
          orderTime: {  
            isShow: true, 
            showLength: true,
            cellWidth: '150px',
            morenName: '单据日期',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            // noModify: true,
            props: 'orderTime',  
          },
          orderNumber: {  
            isShow: true,
            cellWidth: '150px',
            morenName: '单据编号',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            // noModify: false,
            props: 'orderNumber',  
          },
          discountAfterPrice: { 
            isShow: true,
            isSum: true,
            sumValue: 0,
            cellWidth: '180px',
            morenName: '折后金额',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'discountAfterPrice', 
          },
          invoicedOrderAmount: { 
            isShow: true,
            isSum: true,
            sumValue: 0,
            cellWidth: '180px',
            morenName: '已开票金额',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'invoicedOrderAmount',  
          },
          invoicableOrderAmount: {  
            isShow: true,
            isSum: true,
            sumValue: 0,
            cellWidth: '180px',
            morenName: '可开票金额',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'invoicableOrderAmount',  
          },
          nowInvoiceAmount: { 
            isShow: true,
            isSum: true,
            sumValue: 0,
            showType: 'input',
            cellWidth: '180px',
            morenName: '本次开票金额',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'nowInvoiceAmount',  
          },
          remark: {
            isShow: true,
            showType: 'input',
            cellWidth: '150px',
            morenName: '备注',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'remark',
          },
        },
        // 表格数据
        
      // 主表格配置
      TableConfig: {
        // 表头数据
        columnData: {
          idx: {
            isShow: true,
            cellWidth: '70px',
            morenName: '序号',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'idx',
          },
          orderTime: {  
            isShow: true, 
            showLength: true,
            cellWidth: '150px',
            morenName: '单据日期',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            // noModify: true,
            props: 'orderTime',  
          },
          orderNumber: {  
            isShow: true,
            cellWidth: '150px',
            morenName: '单据编号',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            // noModify: false,
            props: 'orderNumber',  
          },
          goodsNumber: {
            isShow: true,
            cellWidth: '150px',
            morenName: '商品编码',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            // noModify: true,
            props: 'goodsNumber',
          },
          goodsName: {  
            isShow: true,
            cellWidth: '150px',
            morenName: '商品名称',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            // noModify: true,
            props: 'goodsName',  
          },
          goodsCode: {  
            isShow: true,
            cellWidth: '150px',
            morenName: '商品条码',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            // noModify: true,
            props: 'goodsCode',  
          },
          goodsNorms: {
            isShow: true,
            cellWidth: '100px',
            morenName: '规格',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'goodsNorms',
          },
          goodsUnit: {
            isShow: true,
            cellWidth: '100px',
            morenName: '单位',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'goodsUnit',
          },
          numberShow: {
            isShow: true,
            isSum: true,
            sumValue: 0,
            cellWidth: '100px',
            morenName: '数量',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'numberShow',
          },
          discountedUnitPrice: {  
            isShow: true,
            isSum: true,
            sumValue: 0,
            cellWidth: '100px',
            morenName: '折扣单价',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'discountedUnitPrice',  
          },
          discountAmount: { 
            isShow: true,
            isSum: true,
            sumValue: 0,
            cellWidth: '100px',
            morenName: '折扣金额',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'discountAmount', 
          },
          taxRate: {
            isShow: true,
            cellWidth: '100px',
            morenName: '税率%',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'taxRate',
          },
          taxAmount: {  
            isShow: true,
            isSum: true,
            sumValue: 0,
            cellWidth: '100px',
            morenName: '税额',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'taxAmount',  
          },
          invoicedOrderAmount: { 
            isShow: true,
            isSum: true,
            sumValue: 0,
            cellWidth: '100px',
            morenName: '已开票金额',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'invoicedOrderAmount',  
          },
          invoicableOrderAmount: {  
            isShow: true,
            isSum: true,
            sumValue: 0,
            cellWidth: '100px',
            morenName: '可开票金额',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'invoicableOrderAmount',  
          },
          nowInvoiceAmount: { 
            isShow: true,
            isSum: true,
            sumValue: 0,
            showType: 'input',
            cellWidth: '100px',
            morenName: '本次开票金额',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'nowInvoiceAmount',  
          },
          remark: {
            isShow: true,
            showType: 'input',
            cellWidth: '100px',
            morenName: '备注',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'remark',
          },
        },
        tableData: [],
      },
      orderStatus: 0, // 当前单据的操作状态
      updateId: '', // 修改列配置时返回的id
      isCreditLimit: false,
      url: {
        exportXlsUrl: '/xghInvoiceInfo/xghInvoiceInfo/exportXls',
      },
      defaultColumnData: [],
      showPriceZeroDialog: false,
      priceZeroGoodsData: {}, //价格为零的商品
      showPriceBelowDialog: false,
      priceBelowGoodsData: {}, //销售价低于成本价的商品
      pageNo: 0, //
      pageTotal: 1,
      lowerLoading: false,
      upperLoading: false,
      printData: {},
      saveData: '', // 预存保存后的数据
      uploadAction: window._CONFIG['domianURL'] + '/sys/common/upload',
     headers: { 'X-Access-Token': Vue.ls.get(ACCESS_TOKEN) },
     attachments: [],
     //  缓存传过来的值
     selectedBills: [],
     selectedDetails: [],
    }
  },
  created() {
    console.log('created')
    if (this.$route.params.invoiceWay == '1' || this.$route.params.invoiceWay == '2') {
      this.TableConfig.columnData = this.byBillcolumnData
    }else{
      this.TableConfig.columnData = this.byCommoditycolumnData
    }
    // 判断是否可查修改销售单价，如果可以则单价的输入框状态为input 反之 为''
    // if (handleOtherPermissions('可查修改销售单价')) {
    //   this.TableConfig.columnData.discountedUnitPrice.showType = 'input'
    // } else {
    //   this.TableConfig.columnData.discountedUnitPrice.showType = ''
    // }

    let accountBook = Vue.ls.get(ACCOUNT_BOOK)
    this.accountBookId = accountBook && accountBook.id


    if (!this.$route.params.invoiceId) {
      //开新单
      this.onNewOrder()
    }
  },
  mounted() {
    console.log('mounted')
    this.getData()
  },
  beforeDestroy() {
    this.$EventBus.$off('getGuideItem')
  },
  watch: {
    orderStatus() {
      this.handleOperationData()
    },
    $route: {
      immediate: true,
      handler() {
        if (this.$route.name == 'invoicesManage-invoicesStatistics-outgoingInfo') {
          let bId = this.$route.params.invoiceId
          if (bId && bId != this.invoiceId) {
            this.invoiceId = bId
            this.getOrderDetailById()
          } else {
            this.onNewOrder()
            console.log('未获取到id')
          }
        }
      },
    },
    'queryData.xghCompanyId': {
      deep: true,
      handler() {
        this.totalCompanys.forEach(item => {
          if (item.id == this.queryData.xghCompanyId) {
            this.xghCompany = item.companyName
          }
        })
      },
    },
    'TableConfig.tableData': {
      handler(newVal, oldVal) {
        if(this.queryData.invoiceWay !== '2'){
          this.calculate();
        }
      },
      deep: true
    },
    'queryData.taxAmount': {
      deep: true,
      handler () {
        if(this.queryData.invoiceWay !== '0'){
          this.queryData.price = formatMoney( delcommafy(this.queryData.priceTaxTotal) - delcommafy(this.queryData.taxAmount)) 
        }
      },
    },
    'queryData.priceTaxTotal': {
      deep: true,
      handler () {
        if(this.queryData.invoiceWay !== '0'){
          this.queryData.price = formatMoney( delcommafy(this.queryData.priceTaxTotal) - delcommafy(this.queryData.taxAmount)) 
        }
      },
    },
    'queryData.invoiceWay': {
      deep: true,
      immediate: true,
      handler () {
        //监听queryData.invoiceWay  如果invoiceWay为0则还原按商品类配置默认值，如果invoiceWay为1则还原按单据类配置默认值
        if (this.queryData.invoiceWay == '0') {
          this.TableConfig.columnData = this.byCommoditycolumnData
        } else {
          this.TableConfig.columnData = this.byBillcolumnData
        }
        this.defaultColumnData = handleObjectToArray(this.TableConfig.columnData)
      },
    },
  },
  methods: {
    calculate(){
      // 初始化计算值
      let totalGoodsPrice = 0;    // 不含税金额总额
      let totalTaxPrice = 0;      // 税额总额
      let totalTaxUnitPrice = 0;  // 价税合计总额
      
      // 确保TableConfig.tableData存在且有数据
      let tableData = this.TableConfig.tableData || []
      let hasValidData = false
      // 检查是否有至少一条包含有效数据的记录
      for (let i = 0; i < tableData.length; i++) {
        const item = tableData[i]
        // 检查是否至少有单据编号
        if (item.orderNumber) {
          hasValidData = true
          break
        }
      }

      if (!hasValidData && this.queryData.invoiceWay != '2') {
        this.queryData.price = 0;          // 不含税金额总额
        this.queryData.taxAmount = 0;         // 税额总额
        this.queryData.priceTaxTotal = 0;
        return
      }
      // 过滤有效数据（至少有goodsId或orderId）
      const validRows = this.TableConfig.tableData.filter(item => 
        item.orderNumber);
      
        if(this.queryData.invoiceWay == '0'){
          // 遍历每一行计算总额
          validRows.forEach(item => {
            console.log('按商品item', item);
            if(Number(item.nowInvoiceAmount) !== 0){
              // 累加计算总额
              totalTaxPrice += delcommafy(delcommafy(item.nowInvoiceAmount) / (1 + (item.taxRate / 100)) || "0") * ((item.taxRate / 100) || "0" );
              // 价税合计等于本次开票金额相加
              totalTaxUnitPrice += delcommafy(item.nowInvoiceAmount || "0");
              totalGoodsPrice += delcommafy(delcommafy(item.nowInvoiceAmount) / (1 + (item.taxRate / 100)) || "0");
            }
          });
        }else if(this.queryData.invoiceWay == '1'){
          // 遍历每一行计算总额
          validRows.forEach(item => {
            console.log('按单据item', item);

            // 累加计算总额
            totalTaxPrice += delcommafy(item.taxAmount || "0");
            totalTaxUnitPrice += delcommafy(item.nowInvoiceAmount || "0");
            totalGoodsPrice += delcommafy(item.nowInvoiceAmount - item.taxAmount);
          });
        }
        
      
      // 更新发票数据显示
      // if (!this.invoiceId) {
        this.queryData.price = formatMoney(totalGoodsPrice);          // 不含税金额总额
        this.queryData.taxAmount = formatMoney(totalTaxPrice);         // 税额总额
        this.queryData.priceTaxTotal = formatMoney(totalTaxUnitPrice); // 价税合计总额
      // }
      
      console.log('发票数据已重新计算:', {
        price: this.queryData.price,
        taxAmount: this.queryData.taxAmount,
        priceTaxTotal: this.queryData.priceTaxTotal
      });
    },
    handleMethodChange(){
      this.queryData.price = 0
      this.queryData.taxAmount = 0
      this.queryData.priceTaxTotal = 0
      this.selectedBills = []
      this.selectedDetails = []
      this.TableConfig.tableData = [{}]
      if(this.queryData.invoiceWay == '1' || this.queryData.invoiceWay == '2'){
        this.TableConfig.columnData = this.byBillcolumnData
      }else{
        this.TableConfig.columnData = this.byCommoditycolumnData
      }
    },
    // 选择回调
    transferBillCallback(data) {
  console.log("传过来的信息", data);
  this.selectedBills = JSON.parse(JSON.stringify(data.billObj || []));
  this.selectedDetails = JSON.parse(JSON.stringify(data.goodsList || []));
  let billObj = data.billObj;
  this.TableConfig.tableData = [];
  if (this.queryData.invoiceWay == '0') { // 按商品添加
    let goodsList = data.goodsList;
    let index = this.TableConfig.tableData.length;

    // 处理商品列表数据
    goodsList.forEach((val) => {
      // console.log('按商品val111111111', val);
      // 累加计算总额
      // totalGoodsPrice += delcommafy(val.goodsPrice || "0");
      // totalTaxPrice += delcommafy(val.taxPrice || "0");
      // totalTaxUnitPrice += delcommafy(val.taxUnitPrice || "0");
      let item = {
       ...val,
       invoiceCategory:1,
        isGive: val.isGive == '1'? false : true,
        // orderId: billObj.id,
        orderTime: val.billDate, // 添加单据日期
        orderNumber: val.billNumber, // 添加单据编号
        goodsNorms: val.norms, // 商品规格
        goodsUnit: val.unit, // 商品单位
        remark: '',
        // 折扣金额
        discountAmount: formatPrice(val.discountAmount),
        discountedUnitPrice: formatPrice(val.discountUnitPrice),
        discountAfterPrice: formatPrice(val.discountAfterPrice),

        // 已开票金额
        invoicedOrderAmount: formatPrice(val.invoicedAmount || val.invoicedOrderAmount),
        // 可开票金额
        invoicableOrderAmount: formatMoney(val.invoicableAmount || val.invoicableOrderAmount),
        // 本次开票金额
        nowInvoiceAmount: formatPrice(val.nowInvoiceAmount),
        number: formatFour(val.number),
        numberShow: formatNumber(val.number),
        notDeliverNumber: formatFour(val.number),
        notDeliverNumberShow: formatNumber(val.number),
        // deliverNumber: formatNumber(0),
        taxAmount: formatPrice((val.goodsPrice || val.salePrice) * (val.taxRate / 100)*(val.number || 0)),
        salePrice: formatFour(val.salePrice || val.goodsPrice),
        allPrice: formatFour(val.allPrice),
        discountedUnitPrice: formatPrice(val.discountUnitPrice),
        salePriceShow: formatPrice(val.salePrice || val.goodsPrice),
        allPriceShow: formatMoney(val.allPrice),
        discountUnitPriceShow: formatPrice(val.discountUnitPrice),
        taxUnitPriceShow: formatPrice(val.taxUnitPrice),
        unitList: val.goodsManyNorms,
        deliverNumber: data.billName == '采购订单'? val.arrivalNumber : '0',
        notDeliverNumber: data.billName == '采购订单'? val.notArrivalNumber : val.number,
        callDocumentId: val.callDocumentId,
        callDocumentType: val.callDocumentType,
      };
      // console.log('商品列表', goodsList);

      // 将计算好的总额赋值给表单数据
    // this.queryData.price = formatMoney(totalGoodsPrice);          // 不含税金额总额
    // this.queryData.taxAmount = formatMoney(totalTaxPrice);        // 税额总额
    // this.queryData.priceTaxTotal = formatMoney(totalTaxUnitPrice); // 价税合计总额
    

    this.TableConfig.tableData.push(item);
    this.$refs.newTableRef.handlePrice(index);
    index++;
    });
  } else if (this.queryData.invoiceWay == '1'){ // 按单据或不标记明细
    console.log('按单据或不标记明细', billObj);
    let index = this.TableConfig.tableData.length;

    billObj.forEach(billObj => {

      console.log('billObj', billObj);
      // 累加计算总额
      // totalGoodsPrice += delcommafy(billObj.price || "0");
      // totalTaxPrice += delcommafy(billObj.taxAmount || "0");
      // totalTaxUnitPrice += delcommafy(billObj.priceTaxTotal || "0");

      let item = {
        ...billObj,
       invoiceCategory:0,
        isGive: billObj.isGive == '1'? false : true,
        orderId: billObj.id,
        orderTime: billObj.createTime,
        orderNumber: billObj.orderNumber,
        goodsNorms: '',
        goodsUnit: '',
        remark: '',
        discountAfterPrice: formatPrice(billObj.discountAfterPrice),

        discountAmount: formatPrice(billObj.discountAmount),
        invoicedOrderAmount: formatPrice(billObj.invoicedOrderAmount !== null ? billObj.invoicedOrderAmount : 0),
        invoicableOrderAmount: formatMoney(billObj.invoicableOrderAmount !== null ? billObj.invoicableOrderAmount : billObj.allPrice),
        invoicedAmount: formatPrice(billObj.invoicedOrderAmount !== null ? billObj.invoicedOrderAmount : 0),
        invoicableAmount: formatPrice(billObj.invoicableOrderAmount !== null ? billObj.invoicableOrderAmount : billObj.allPrice),
        // nowInvoiceAmount: formatPrice(billObj.invoicableOrderAmount !== null ? billObj.invoicableOrderAmount : billObj.allPrice),
        nowInvoiceAmount: formatPrice(0),
        number: formatFour(billObj.number),
        numberShow: formatNumber(billObj.numberShow),
        notDeliverNumber: formatFour(billObj.notDeliverNumber),
        notDeliverNumberShow: formatNumber(billObj.notDeliverNumberShow),
        deliverNumber: formatNumber(billObj.deliverNumber),
        // taxRate: this.queryDatataxRate,
        taxAmount: formatFour(billObj.taxAmount),
        salePrice: formatFour(billObj.allPrice),
        allPrice: formatFour(billObj.allPrice),
        discountedUnitPrice: formatFour(billObj.discountUnitPrice),
        salePriceShow: formatPrice(billObj.allPrice),
        allPriceShow: formatMoney(billObj.allPrice),
        discountUnitPriceShow: formatPrice(billObj.discountUnitPrice),
        taxUnitPriceShow: formatPrice(billObj.taxUnitPrice),
        unitList: [],
        callDocumentId: billObj.id,
        callDocumentType: this.billType,
        departmentId: billObj.departmentId,
        departmentName: billObj.departmentName,
        storeName: billObj.storeName,
        userName: billObj.userName || billObj.createBy
      };

      // 将计算好的总额赋值给表单数据
    // this.queryData.price = formatMoney(totalGoodsPrice);          // 不含税金额总额
    // this.queryData.taxAmount = formatMoney(totalTaxPrice);        // 税额总额
    // this.queryData.priceTaxTotal = formatMoney(totalTaxUnitPrice); // 价税合计总额
      
    this.TableConfig.tableData.push(item);
    this.$refs.newTableRef.handlePrice(index);
    index++;
    });
  }

  // 处理公式计算
  for (let index = 0; index < this.TableConfig.tableData.length; index++) {
    const element = this.TableConfig.tableData[index];
    if (element.formulaId) {
      this.$refs.newTableRef.formulaChange(element.formulaId, element, index);
    }
  }
},
    getAuto(){
      // 表格内容不为空 原始表格为[{}]
      let tableData = this.TableConfig.tableData || []
      let hasValidData = false
      // 检查是否有至少一条包含有效数据的记录
      for (let i = 0; i < tableData.length; i++) {
        const item = tableData[i]
        // 检查是否至少有单据编号
        if (item.orderNumber) {
          hasValidData = true
          break
        }
      }

      if (!hasValidData) {
        this.$elMessage.warning('发票明细为空,无法自动分配！')
        return
      }
      if (!this.queryData.invoicePrice) { //开票金额
        this.$elMessage.warning('请输入开票金额!!!')
        return
      }
      // 提示:自动分配会覆盖本次开票金额,是否继续 是 否
      this.tipsData.tipsWords = '自动分配会覆盖本次开票金额,是否继续？'
      this.tipsData.tipsMark = 'Automatic'
      this.$refs.reminderRef.dialogVisible = true
    },
    autoAssign(){
      // 自动分配
      //将输入的开票金额从上往下自动分配到表格每条数据的本次开票金额 比如开票金额输入100 表格第一条数据可开票金额为80需要将这条数据的本次开票金额赋值为80 比如第二条数据可开票金额为20 需要将这条数据的本次开票金额赋值为20 如果开票金额输入100 表格第一条数据可开票金额为80 第二条数据可开票金额为60 需要将这条数据的本次开票金额赋值为剩下的20
      if(this.queryData.invoicePrice){
        // 如果this.queryData.invoicePrice输入的不是数字提示请输入正确格式
        if(isNaN(delcommafy(this.queryData.invoicePrice))){
          this.$elMessage.warning('请输入正确开票金额格式！')
          return
        }
      }
      let remainingAmount = delcommafy(this.queryData.invoicePrice);
    this.TableConfig.tableData.forEach(item => {
      console.log('item.invoicableAmount', item.invoicableAmount);
        if (remainingAmount > 0) {
            if (remainingAmount >= item.invoicableAmount) {
                item.nowInvoiceAmount = formatPrice(item.invoicableAmount);
                remainingAmount -= item.invoicableAmount;
            } else {
                item.nowInvoiceAmount = formatPrice(remainingAmount);
                remainingAmount = 0;
            }
        } else {
            item.nowInvoiceAmount = formatPrice(0);
        }
    })
    // 提示:系统已自动分配
    this.$elMessage.success('系统已自动分配开票金额！');
  },
    getAdd(){
      if(!this.queryData.xghCompanyId){
        this.$elMessage.warning('请先选择供应商！')
        return
      }
      this.$refs.dialogInvoice.show({
            title: "销项发票信息",
            api: "调单-销项发票信息",
            detailApi: "调单-销项发票信息明细",
            listUrl: '/xghSaleStorehouseOrder/xghSaleStorehouseOrder/list', //销售出库单列表
            detailUrl: '/xghSaleStorehouseOrder/xghSaleStorehouseOrder/getBuyOrderById', //销售出库单据明细
            orderKey: 'saleStorehouseOrderPage',
            goodsListKey: 'xghSaleStorehouseOrderInfoList',
            xghCompanyId: this.queryData.xghCompanyId,
            orderStatusKey: 'orderStatus',
            invoiceCategory:this.queryData.invoiceWay == '1' ? 0 : this.queryData.invoiceWay == '0' ? 1 : '',
            billType:6,
            // 传递已选择的单据和明细记录
            selectedBills: this.selectedBills || [],
            selectedDetails: this.selectedDetails || []
          })
    },
    getDel(){
      this.TableConfig.tableData = [{}]
      this.selectedBills = []; // 清空已选单据数据
      this.selectedDetails = []; // 清空已选明细数据
      // 调用子组件clearSelected方法
      this.$refs.dialogInvoice.clearSelected();
    },
    // 部门
    filterMethodByDept (e) {
      if (this.activeOptions.length == 0) {
        this.activeOptions = Object.assign([], this.deptOptions)
      }
      if (e) {
        this.deptOptions = this.activeOptions.filter(item => {
          console.log(item.deptName);
          return item.deptName.indexOf(e) > -1
        })
      } else {
        this.deptOptions = Object.assign([], this.activeOptions)
      }
    },
    // 发票类型
    handleFilterInvoiceType(e) {
      if (this.activeFpOptions.length === 0) {
        this.activeFpOptions = Object.assign([], this.fpOptions);
      }
      if (e) {
        this.fpOptions = this.activeFpOptions.filter(item => {
          return item.label.indexOf(e) > -1;
        });
      } else {
        this.fpOptions = Object.assign([], this.activeFpOptions);
      }
    },
  visibleChange (e) {
      if (!e) {
        this.activeOptions = []
      }
    },
    visibleChangeFp (e) {
      if (!e) {
        this.activeFpOptions = []
      }
    },
    visibleChangeKp (e) {
      if (!e) {
        this.activeKpOptions = []
      }
    },
    getSelectList () {
        // 所属部门
        getAction('/dept/xghAccountBookDept/getDeptByAbId', {}).then((res) => {
          if (res.code === 200) {
            this.deptOptions = res.result
          }
        })
    },
    onAddDeptTree () {
      console.log('onAddDeptTree');
      this.newTreeData = {
        data: { id: '0' },
        state: 'add',
        module: {
          name: 'deptName', //类别名称字段
          code: 'deptCode', //类别编码字段
          pyCode: 'pinYinCode', //类别拼音码字段
          indexCode: 'backup', //备注字段
        },
        getTreeUrl: '/dept/xghAccountBookDept/getDeptByAbId', //获取类别接口
        deleteTreeUrl: '/xgh/section/deleteById', //删除类别接口
        addTreeUrl: '/dept/xghAccountBookDept/add', //新增类别接口
        editTreeUrl: '/xgh/section/edit', //修改类别接口
      }
      this.$refs.deptSelect.blur()
      this.showNewTree = true
    },
    onShowTreeByDept () {
      this.toTreeData = {
        module: {
          name: 'deptName', //类别名称字段
          code: 'sectionCode', //类别编码字段
          pyCode: 'pinyinCode', //类别拼音码字段
          indexCode: 'indexCode', //类别排序码字段
          pid: 'parentId', //父级id字段
        },
        getTreeUrl: '/dept/xghAccountBookDept/getDeptByAbId', //获取类别接口
        deleteTreeUrl: '/xgh/section/deleteById', //删除类别接口
        addTreeUrl: '/xgh/section/add', //新增类别接口
        editTreeUrl: '/xgh/section/edit', //修改类别接口
      }
      this.$refs.treeRef.getTreeData(this.toTreeData)
      this.$refs.treeRef.dialogVisible = true
    },
    supplementChange(val) {
      if (!val) {
        this.queryData.orderTime = this.$formatDateTime()
      }
    },
    // 打印
    handleShortcutKeyPrint() {
      if (!this.buttonsPermissions.DaYin) {
        this.$elMessage.warning('未拥有打印权限！')
      } else if (this.orderStatus == 66) {
        this.$elMessage.warning('当前状态不支持打印操作！')
      } else {
        console.log('快捷键打印-销项发票信息')
        // let temp = JSON.parse(JSON.stringify(this.printData))
        // 可以多次打印设置
        if (this.printPermissions) {
          this.$refs.print.show(this.printData, this.TableConfig.columnData, this.queryData.invoiceWay == '0' ? '发票信息按商品' : this.queryData.invoiceWay == '1' ? '发票信息按单据' : '发票信息不标记明细')
        } else {
          if (this.$lcStorage.get('printLimitValue')) {
            // 获取打印次数
            this.getPrintNum(this.invoiceId, (() => {
              this.$refs.print.show(this.printData, this.TableConfig.columnData, this.queryData.invoiceWay == '0' ? '发票信息按商品' : this.queryData.invoiceWay == '1' ? '发票信息按单据' : '发票信息不标记明细')
            }))
          } else {
            this.$refs.print.show(this.printData, this.TableConfig.columnData, this.queryData.invoiceWay == '0' ? '发票信息按商品' : this.queryData.invoiceWay == '1' ? '发票信息按单据' : '发票信息不标记明细')
          }
        }
      }
    },
    beforeUpload(file) {
      let type = file.type.toLowerCase()
      const isJPG = type.includes('png') || type.includes('jpeg') || type.includes('jpg')
      const isLt2M = file.size / 1024 / 1024 < 2
      if (!isJPG) {
        this.$message.error('请上传png/jpg/jpeg格式的图片!')
      }
      if (!isLt2M) {
        this.$message.error('上传图片大小不能超过 2MB!')
      }
      return isJPG && isLt2M
    },
    handleSuccess(e) {
      console.log(e)
      if (e.success) {
        if (this.attachments.length < 5) {
          this.attachments.push(e.message)
        } else {
          this.$message.error('最多支持上传5张!')
        }
      }
    },
    delAttachment(index) {
      this.attachments.splice(index, 1)
    },
    // 获取数据
    getData() {
      this.getGysStorage() //初始化默认获取缓存中存储的曾经点击过的供应商数据
      this.getStaffData() // 获取所有员工数据
      this.getAccountData() // 获取账户信息数据
      this.getSelectList() // 所属部门
      this.selectTitle()
    },
    //查看单据详情
    getOrderDetailById() {
      getAction('/xghInvoice/xghInvoice/queryById', { id: this.invoiceId  }).then((res) => {
        if (res.success) {
          this.handleData(res.result)
        } else {
          this.$elMessage.error(res.message)
        }
      })
    },
    async selectTitle() {
      let obj = await this.$setColumn.selectColumn(this.pageName)
      let gObj = await this.$setColumn.selectColumn('商品信息')
      if (obj.code === 200) {
        this.updateId = obj.updateId
        // this.TableConfig.columnData = obj.columnData
        if (this.queryData.invoiceWay == '0') {
          this.TableConfig.columnData = this.byCommoditycolumnData
        } else {
          this.TableConfig.columnData = this.byBillcolumnData
        }
      } else if (obj.code === 500) {
        let id = await this.$setColumn.addColumn(this.pageName, this.$options.data().TableConfig.columnData)
        this.updateId = id
      }
      let defaultlist = this.$options.data().TableConfig.columnData
      if (gObj.code === 200) {
        let list = gObj.columnData
        list.forEach(element => {
          if (element.props.includes('extendField')) {
            if (this.TableConfig.columnData[element.props]) {
              this.TableConfig.columnData[element.props].zidingyiName = element.zidingyiName
            }
            if (defaultlist[element.props]) {
              defaultlist[element.props].zidingyiName = element.zidingyiName
            }
          }
        });
      }
      // this.defaultColumnData = handleObjectToArray(defaultlist)
    },
    // 修改列配置后保存修改后的值
    async onSaveColumn(value) {
      this.TableConfig.columnData = handleArrayToObject(value, 'props')
      let res = await this.$setColumn.editColumn(this.pageName, this.TableConfig.columnData, this.updateId)
      if (res.code == 200) {
        this.$elMessage.success(res.message)
      } else {
        this.$elMessage.error(res.message)
      }
    },
    onUpdateColumn() {
      this.onSaveColumn(handleObjectToArray(this.TableConfig.columnData))
    },
     // 打开列配置弹框
     onShowColumn() {
      // this.defaultColumnData = handleObjectToArray(this.$options.data().TableConfig.columnData)
      this.$refs.setColumnRef.dialogVisible = true
    },
    // 列宽发生变化时触发
    onDragColumn(val) {
      this.$setColumn.editColumn(this.url.api, this.TableConfig.columnData, this.updateId)
    },
    /**
     * 初始化默认获取缓存中存储的曾经点击过的供应商数据
     */
    getGysStorage() {
      getAction('/xghCompany/xghCompany/listNoPage', {}).then((res) => {
        if (res.code === 200) {
          this.gysOptions = res.result
          this.totalCompanys = res.result
        } else {
          this.$elMessage.error(res.message)
        }
      })
    },
    /**
     * 获取所有员工数据
     */
    async getStaffData() {
      getAction('/dept/xghAccountBookDept/getAllDeptUsers', {}).then((res) => {
        if (res.code === 200) {
          this.jsrOptions = res.result
          this.totalPersons = res.result
          // 默认经手人设置
          this.queryData.sysUserId = this.$lcStorage.get('xghUser').id
        }
      })
    },
    /**
     * 获取多账户信息数据
     */
    async getAccountData() {
      const data = await getAction('/xghBank/xghBank/listNoPage', {})
      if (data.code !== 200) {
        return this.$elMessage.error('获取数据失败！')
      }
      this.paymentData = []
      for (let i = 0; i < data.result.length; i++) {
        this.paymentData.push({
          xh: i + 1,
          id: data.result[i].id,
          bankName: data.result[i].bankName,
          isDefault: data.result[i].defaultFlag,
          price: 0,
          xhState: true,
        })
      }
      this.originPaymentDat = JSON.parse(JSON.stringify(this.paymentData))
    },
    // 处理操作下拉列表的启用禁用项
    handleOperationData() {
      if (this.orderStatus == 66 || this.orderStatus == 0) {
        this.importValue = '导入'
      } else {
        this.importValue = '导出'
      }
      //orderStatus 订单状态：0待审核、5审核通过、10作废、15反审、20红冲、25终止、30完成
      let allList = ['作废', '反审', '红冲', '终止', '完成', '复制单据', '办理过程']
      let result = []
      // 、、判断订单状态
      if (this.orderStatus == 66) {
        // 新单
        result = ['终止']
      } else if (this.orderStatus == 0 || this.orderStatus == 15) {
        // 保存/反审
        if (this.buttonsPermissions.ZuoFei) {
          result = ['作废', '终止']
        } else {
          result = ['终止']
        }
      } else if (this.orderStatus == 5) {
        // 审核后
        let list = []
        if (this.buttonsPermissions.FanShen) {
          list.push('反审')
        }
        if (this.buttonsPermissions.HongChong) {
          list.push('红冲')
        }
        result = list.concat(['终止', '完成'])
      } else if (this.orderStatus == 10 || this.orderStatus == 20) {
        // 作废/红冲
        result = []
      } else if (this.orderStatus == 30) {
        // 完成
        result = []
        if (this.buttonsPermissions.HongChong) {
          result = ['红冲']
        }
      } else if (this.orderStatus == 25) {
        // 终止
        result = []
        if (this.buttonsPermissions.ZuoFei) {
          result = ['作废']
        }
      }
      // 判断执行状态
      // 执行状态 0未完成 1已完成 2已终止
      if (this.queryData.performState == 2) {
        //终止
        result = []
        if (this.buttonsPermissions.ZuoFei && this.orderStatus != 10) {
          result = ['作废']
        }
      } else if (this.queryData.performState == 1 && this.orderStatus != 20) {
        result = []
        if (this.buttonsPermissions.HongChong) {
          result = ['红冲']
        }
      }
      result = result.concat(['复制单据', '办理过程'])
      let resultList = []
      allList.forEach((item) => {
        let newItem = {
          value: item,
          disabled: result.indexOf(item) == -1,
        }
        resultList.push(newItem)
      })
      this.operationData = resultList
    },

    // 点击开新单
    onNewOrder() {
      // this.$nextTick(() => {
      //   // 新单时，更新扩展字段数据
      //   this.$refs.extendedFieldsRef.updateTableData('new')
      // })
      console.log('当前订单状态:', this.orderStatus)
      // 1.先判断当前页面的值是否保存，用弹出框给用户提醒
      if (this.orderStatus === 66 && this.getHaveChange()) {
        this.tipsData.tipsWords = '当前单据还未保存，</br>是否继续？'
        this.tipsData.tipsMark = 'onNewOrder'
        this.$refs.reminderRef.dialogVisible = true
      } else {
        this.selectedBills = []
        this.selectedDetails = []
        this.orderFlag = 0
        this.pageNo = 0
        this.pageTotal = 1
        this.orderStatus = 66
        this.invoiceStatus = 0
        this.invoiceId = ''
        this.logData.orderId = -1
        this.queryData = JSON.parse(JSON.stringify(this.$options.data().queryData))
        this.taxRate = 0 // 重置税率
        // this.ckOptions.forEach(item =>{
        //   if (item.isDefault == 1) {
        //     this.queryData.xghStorehouseId = item.id
        //   }
        // })
        // 默认经手人设置
        this.queryData.sysUserId = this.$lcStorage.get('xghUser').id
        this.attachments = []
        this.queryData.invoiceTime = this.$formatDateTime()
        this.queryData.createOrderDate = this.$formatDateTime()
        this.queryData.createUserName = this.$lcStorage.get('xghUser').realname
        this.isCreditLimit = false
        this.paymentEcho = {
          xghCollectionPayInfoList: [],
        }
        this.$nextTick(() => {
          this.$refs.newTableRef.getSubData()
          this.$refs.newTableRef.onResetCommodity()
        })
      }
    },
    priceZeroCallback(data) {
      console.log(data)
      if (data.type == 'once') {
        this.TableConfig.tableData[data.index].ignore = true
        this.showPriceZeroDialog = false
        this.onSubmit()
      } else if (data.type == 'cancel') {
        this.showPriceZeroDialog = false
      } else if (data.type == 'all') {
        for (let index = 0; index < this.TableConfig.tableData.length; index++) {
          let element = this.TableConfig.tableData[index]
          element.ignore = true
        }
        this.showPriceZeroDialog = false
        this.onSubmit()
      }
    },
    getZeroByGoods() {
      let list = this.TableConfig.tableData
      for (let index = 0; index < list.length; index++) {
        const element = list[index]
        if (element.discountedUnitPrice == formatPrice(0) && !element.ignore) {
          this.showPriceZeroDialog = true
          let item = {
            id: element.id,
            name: `商品[${element.goodsName}]销售单价`,
            index,
          }
          this.priceZeroGoodsData = item
          return true
        }
      }
      return false
    },
    priceBelowCallback(data) {
      console.log(data)
      if (data.type == 'cancel') {
        this.showPriceBelowDialog = false
      } else {
        if (data.index == 1) {
          this.showPriceBelowDialog = false
          this.isCreditLimit = true
          this.onSubmit()
        } else {
          this.showPriceBelowDialog = false
          for (let index = 0; index < this.TableConfig.tableData.length; index++) {
            let element = this.TableConfig.tableData[index]
            element.compulsory = '1'
          }
          this.onSubmit()
        }
      }
    },
    getBelowByGoods() {
      let list = this.TableConfig.tableData
      let goodsName = ''
      for (let index = 0; index < list.length; index++) {
        const element = list[index]
        if (delcommafy(element.discountedUnitPrice) < parseFloat(element.costPrice) && element.compulsory == 0) {
          if (goodsName.length == 0) {
            goodsName = element.goodsName
          } else {
            goodsName = goodsName + '，' + element.goodsName
          }
        }
      }
      if (goodsName.length > 0) {
        this.showPriceBelowDialog = true
        let item = {
          id: '',
          name: `商品[${goodsName}]销售单价低于成本价`,
          index: 0,
        }
        this.priceBelowGoodsData = item
        return true
      }
      return false
    },
    // 保存
    // async onSubmit() {
    //   if (!this.queryData.xghCompanyId) {
    //     this.$elMessage.warning('客户不能为空，请选择！')
    //     return
    //   }
    //   if (!this.queryData.xghStorehouseId) {
    //     this.$elMessage.warning('出货仓库不能为空，请选择！')
    //     return
    //   }
    //   if (this.isInputSkip) {
    //     if (this.getZeroByGoods()) {
    //       return
    //     }
    //   }
    //   if (this.isBelowCost) {
    //     if (this.getBelowByGoods()) {
    //       return
    //     }
    //   }

    //   let queryObj = JSON.parse(JSON.stringify(this.queryData))
    //   // 给补单 赠品的数据转换为后端需要的类型
    //   queryObj.isSupplement = queryObj.isSupplement ? '0' : '1' //是否补单-0：是 1:不是

    //   let count = 0
    //   let digest = []
    //   let newTableData = JSON.parse(JSON.stringify(this.TableConfig.tableData))
    //   let list = newTableData.map(item => {
    //     if (item.goodsId) {
    //       item.isGive = item.isGive ? '0' : '1' //赠品0:是赠品1：不是赠品
    //       item.discountedUnitPrice = formatFour(delcommafy(item.discountedUnitPrice))
    //       item.taxAmount = formatFour(delcommafy(item.taxAmount))
    //       item.allPrice = formatFour(delcommafy(item.allPrice))
    //       if (Number(item.number) == 0) {
    //         count++
    //       }
    //       digest.push(`[${item.goodsName},${item.numberShow}${item.unit}]`)
    //       return item
    //     }
    //   }).filter(item => {
    //     return item != undefined
    //   })
    //   if (list.length == 0) {
    //     this.$elMessage.warning('商品不能为空，请选择商品！')
    //     return
    //   } else if (count > 0) {
    //     this.$elMessage.warning('商品数量不能为0')
    //     return
    //   }

    //   let orderObj = {
    //     ...queryObj,
    //     attachment: this.attachments.join(','), //附件
    //     summary: digest.join(';'), //摘要
    //     orderDiscountPrice: delcommafy(queryObj.orderDiscountPrice), //移除需要参与计算的数值千分位分隔符
    //     purchaseOrderPrice: delcommafy(queryObj.purchaseOrderPrice),
    //     arrearsPrice: delcommafy(queryObj.arrearsPrice),
    //     depositPrice: delcommafy(queryObj.depositPrice),
    //     orderAllPrice: delcommafy(queryObj.orderAllPrice),
    //     type: 1,
    //     xghAccountBookId: this.accountBookId,
    //     xghSaleOrderInfoList: list,
    //     performState: this.invoiceId ? queryObj.performState : 0, //执行状态
    //     compulsoryCredit: this.isCreditLimit ? '1' : '0',
    //     createOrderDate: this.invoiceId ? queryObj.createOrderDate : ""
    //   }

    //   // 整单优惠金额不能大于合计金额
    //   if (orderObj.orderDiscountPrice > orderObj.allPrice) {
    //     this.$elMessage.warning('整单优惠金额不能大于合计金额')
    //     return
    //   }
    //   //本次付款金额不能大于应付金额
    //   if (orderObj.depositPrice > orderObj.purchaseOrderPrice) {
    //     this.$elMessage.warning('预收定金不能大于应收金额')
    //     return
    //   }
    //   if (orderObj.depositPrice != 0 && !orderObj.bankName) {
    //     this.$elMessage.warning('预收定金不为0时账户信息不能为空')
    //     return
    //   }


    //   // 预付定金  depositPrice， 单据金额  purchaseOrderPrice
    //   let p = delcommafy(queryObj.purchaseOrderPrice)
    //   let d = delcommafy(this.queryData.depositPrice)
    //   let status = '0'
    //   if (p == 0 || p == d) {
    //     status = '2'
    //   } else if (d < p && d > 0) {
    //     status = '1'
    //   }
    //   //支付信息
    //   this.paymentEcho.xghCollectionPayInfoList.forEach((item) => {
    //     if (item.price > 0) {
    //       item.price = -item.price
    //     }
    //   })
    //   let payObj = {
    //     ...this.paymentEcho,
    //     isBegin: 1, //是否期初0：是期初 1：不是
    //     isDeposit: 0, //是否定金0:是1:不是
    //     payType: 1, //收付类型1:收款2：付款
    //     price: 0,
    //     orderType: '5', //采购订单1/采购入库单2/采购退货单3/采购换货单4/销售订单5/销售出库单6/销售退货单7/销售换货单8/盘点单9/报损单10
    //     companyId: this.queryData.xghCompanyId,
    //     companyType: '2',
    //     xghAccountBookId: this.accountBookId,
    //     settlementStatus: '0', //结算单状态0保存 5.审核 20 红冲
    //     status, //结销状态0：未结1：部分结销2:已结销
    //     receivablePrice: -delcommafy(queryObj.depositPrice), //应收金额
    //     balance: -delcommafy(queryObj.depositPrice),
    //     documentsName: this.pageName,
    //     documentsType: this.getBillTypeByText(this.pageName)
    //   }
    //   orderObj.closingStatus = status //单据信息携带结销状态

    //   // 处理扩展字段多选时的选项
    //   const submitExtendFields = JSON.parse(JSON.stringify(this.$refs.extendedFieldsRef.getTableData()))
    //   submitExtendFields.forEach((item) => {
    //     if (item.fieldType === 'selectMultiple' && Array.isArray(item.fieldValue)) {
    //       console.log(item.fieldValue, '进入循环了')
    //       item.fieldValue = item.fieldValue.join(',')
    //     }
    //   })

    //   // 总信息
    //   let obj = {
    //     collectionPayPage: payObj, //
    //     saleOrderPage: orderObj,
    //     extendFields: submitExtendFields
    //   }
    //   console.log('保存：', orderObj)
    //   var res = {}
    //   // 修改
    //   if (this.invoiceId) {
    //     // 先判断用户是否拥有修改权限
    //     if (this.buttonsPermissions.XiuGai) {
    //       res = await postAction('/xghSaleOrder/xghSaleOrder/edit', obj)
    //     } else {
    //       this.showTips('没有修改权限！')
    //       return
    //     }
    //   } else {
    //     // 新增
    //     res = await postAction('/xghSaleOrder/xghSaleOrder/add', obj)
    //   }
    //   if (res.code === 200) {
    //     if (this.queryData.id) {
    //       this.$elMessage.success('修改成功！')
    //     } else {
    //       this.$elMessage.success('新增成功！')
    //     }
    //     // this.tipsData.resultType = 1
    //     // this.$refs.successRef.dialogVisible = true
    //     this.handleData(res.result)
    //     this.isCreditLimit = false
    //     this.toSaveOrExamine()
    //     // 保存后更新扩展字段
    //     this.$refs.extendedFieldsRef.updateTableData(res.result.extendFields)
    //   } else if (res.code == 303) {
    //     this.showPriceBelowDialog = true
    //     let item = {
    //       id: '',
    //       name: `商品${res.message}销售单价低于成本价`,
    //       index: 0,
    //     }
    //     this.priceBelowGoodsData = item
    //   } else if (res.code == 101) {
    //     this.showPriceBelowDialog = true
    //     let item = {
    //       id: '',
    //       name: `${res.message}`,
    //       index: 1,
    //     }
    //     this.priceBelowGoodsData = item
    //   } else {
    //     this.showTips(res.message)
    //   }
    // },
    // 保存
    // async onSubmit() {
    //   // 总信息
    //   // let obj = {
    //   //   collectionPayPage: payObj, //
    //   //   saleOrderPage: orderObj,
    //   //   extendFields: submitExtendFields
    //   // }
    //   if (!this.queryData.xghCompanyId) {
    //     this.$elMessage.warning('供应商不能为空，请选择！')
    //     return
    //   }
    //   if (!this.queryData.invoiceType) {
    //     this.$elMessage.warning('发票类型不能为空，请选择！') //发票类型
    //     return
    //   }
    //   if (!this.queryData.invoicePrice) { //开票金额
    //     this.$elMessage.warning('开票金额不能为空，请输入！')
    //     return
    //   }
    //   if (!this.queryData.invoiceWay) { //开票方式
    //     this.$elMessage.warning('开票方式不能为空，请选择！')
    //     return
    //   }
    //   console.log('保存：', 11111111111111)
    //   var res = {}
    //   // 修改
    //   if (this.queryData.id) {
    //     // 先判断用户是否拥有修改权限
    //     if (this.buttonsPermissions.XiuGai) {
    //       res = await postAction('/xghInvoice/xghInvoice/edit', {xghInvoiceInfoList:[...this.TableConfig.tableData]})
    //     } else {
    //       this.showTips('没有修改权限！')
    //       return
    //     }
    //   } else {
    //     // 新增
    //     res = await postAction('/xghInvoice/xghInvoice/add',{ xghInvoiceInfoList:[...this.TableConfig.tableData]})
    //   }
    //   if (res.code === 200) {
    //     if (this.queryData.id) {
    //       this.$elMessage.success('修改成功！')
    //     } else {
    //       this.$elMessage.success('新增成功！')
    //     }
    //     // this.tipsData.resultType = 1
    //     // this.$refs.successRef.dialogVisible = true
    //     this.handleData(res.result)
    //     this.isCreditLimit = false
    //     this.toSaveOrExamine()
    //     // 保存后更新扩展字段
    //     this.$refs.extendedFieldsRef.updateTableData(res.result.extendFields)
    //   } else if (res.code == 303) {
    //     this.showPriceBelowDialog = true
    //     let item = {
    //       id: '',
    //       name: `商品${res.message}销售单价低于成本价`,
    //       index: 0,
    //     }
    //     this.priceBelowGoodsData = item
    //   } else if (res.code == 101) {
    //     this.showPriceBelowDialog = true
    //     let item = {
    //       id: '',
    //       name: `${res.message}`,
    //       index: 1,
    //     }
    //     this.priceBelowGoodsData = item
    //   } else {
    //     this.showTips(res.message)
    //   }
    // },
    async onSubmit() {
      if (!this.queryData.xghCompanyId) {
        this.$elMessage.warning('供应商不能为空，请选择！')
        return
      }
      if (!this.queryData.invoiceType) {
        this.$elMessage.warning('发票类型不能为空，请选择！') //发票类型
        return
      }
      if (!this.queryData.invoiceNumber) { //发票号
        this.$elMessage.warning('请输入发票号码！')
        return
      }
      if (this.queryData.price < 0) { //不含税金额不能小于0
        this.$elMessage.warning('不含税金额不能小于0！')
        return
      }
      if (this.queryData.taxAmount < 0) { //税额不能小于0
        this.$elMessage.warning('税额不能小于0！')
        return
      }
      if (this.queryData.priceTaxTotal < 0) { //价税合计不能小于0
        this.$elMessage.warning('价税合计不能小于0！')
        return
      }
      // 表格内容不为空 原始表格为[{}]
      let tableData = this.TableConfig.tableData || []
      let hasValidData = false
      // 检查是否有至少一条包含有效数据的记录
      for (let i = 0; i < tableData.length; i++) {
        const item = tableData[i]
        // 检查是否至少有单据编号
        // if (delcommafy(item.nowInvoiceAmount) > delcommafy(item.invoicableAmount)) {
        //   this.$elMessage.warning('开票金额不能大于可开票金额！')
        //   return
        // }
        if (item.orderNumber) {
          hasValidData = true
          break
        }
      }

      if (this.queryData.invoiceWay !== '2') {
        if (!hasValidData) {
          this.$elMessage.warning('请先添加有效的发票明细数据！')
          return
        }
      } else {
        // 发票金额需要等于价税合计
        if (delcommafy(this.queryData.invoicePrice) != delcommafy(this.queryData.priceTaxTotal)) {
          return this.$elMessage.warning('开票金额不等于价税合计金额，请输入！！！')
        }
      }
      
      this.queryData.invoicePrice = delcommafy(this.queryData.invoicePrice);
      let queryObj = JSON.parse(JSON.stringify(this.queryData))

      // let count = 0
      // let digest = []
      // let newTableData = JSON.parse(JSON.stringify(this.TableConfig.tableData))
      // let list = newTableData.map(item => {
      //   if (item.goodsId) {
      //     item.isGive = item.isGive ? '0' : '1' //赠品0:是赠品1：不是赠品
      //     item.discountedUnitPrice = formatFour(delcommafy(item.discountedUnitPrice))
      //     item.taxAmount = formatFour(delcommafy(item.taxAmount))
      //     item.allPrice = formatFour(delcommafy(item.allPrice))
      //     // if (Number(item.number) == 0) {
      //     //   count++
      //     // }
      //     digest.push(`[${item.goodsName},${item.numberShow}${item.unit}]`)
      //     return item
      //   }
      // }).filter(item => {
      //   return item != undefined
      // })
      // if (list.length == 0) {
      //   this.$elMessage.warning('单据信息不能为空，请选择单据！')
      //   return
      // }
      // //  else if (count > 0) {
      // //   this.$elMessage.warning('商品数量不能为0')
      // //   return
      // // }

      let orderObj = {
        ...queryObj,
        price: delcommafy(queryObj.price), //移除需要参与计算的数值千分位分隔符
        priceTaxTotal: delcommafy(queryObj.priceTaxTotal),
        taxAmount: delcommafy(queryObj.taxAmount),
      }

      let p = this.TableConfig.tableData.map(item => ({
        ...item,
        goodsPrice:item.salePrice,
        allPriceShow: delcommafy(item.allPriceShow), //移除需要参与计算的数值千分位分隔符
        discountAfterPrice: delcommafy(item.discountAfterPrice), //移除需要参与计算的数值千分位分隔符
        discountAmount: delcommafy(item.discountAmount), //移除需要参与计算的数值千分位分隔符
        invoicableOrderAmount: delcommafy(item.invoicableOrderAmount), //移除需要参与计算的数值千分位分隔符
        invoicedOrderAmount: delcommafy(item.invoicedOrderAmount), //移除需要参与计算的数值千分位分隔符
        salePriceShow: delcommafy(item.salePriceShow), //移除需要参与计算的数值千分位分隔符
        taxUnitPriceShow: delcommafy(item.taxUnitPriceShow), //移除需要参与计算的数值千分位分隔符
        numberShow: delcommafy(item.numberShow), //移除需要参与计算的数值千分位分隔符
        notDeliverNumberShow: delcommafy(item.notDeliverNumberShow), //移除需要参与计算的数值千分位分隔符
        invoicableAmount: delcommafy(item.invoicableAmount),
        discountUnitPriceShow: delcommafy(item.discountUnitPriceShow), //移除需要参与计算的数值千分位分隔符
        discountedUnitPrice: delcommafy(item.discountedUnitPrice), //移除需要参与计算的数值千分位分隔符
        nowInvoiceAmount: delcommafy(item.nowInvoiceAmount), //移除需要参与计算的数值千分位分隔符
        invoicableAmount: delcommafy(item.invoicableAmount), //移除需要参与计算的数值千分位分隔符
        taxAmount: delcommafy(item.taxAmount), //移除需要参与计算的数值千分位分隔符
        id: ''
      }))

      let e = this.TableConfig.tableData.map(item => ({
        ...item,
        goodsPrice:item.salePrice,
        allPriceShow: delcommafy(item.allPriceShow), //移除需要参与计算的数值千分位分隔符
        discountAfterPrice: delcommafy(item.discountAfterPrice), //移除需要参与计算的数值千分位分隔符
        discountAmount: delcommafy(item.discountAmount), //移除需要参与计算的数值千分位分隔符
        invoicableOrderAmount: delcommafy(item.invoicableOrderAmount), //移除需要参与计算的数值千分位分隔符
        invoicedOrderAmount: delcommafy(item.invoicedOrderAmount), //移除需要参与计算的数值千分位分隔符
        salePriceShow: delcommafy(item.salePriceShow), //移除需要参与计算的数值千分位分隔符
        taxUnitPriceShow: delcommafy(item.taxUnitPriceShow), //移除需要参与计算的数值千分位分隔符
        numberShow: delcommafy(item.numberShow), //移除需要参与计算的数值千分位分隔符
        notDeliverNumberShow: delcommafy(item.notDeliverNumberShow), //移除需要参与计算的数值千分位分隔符
        invoicableAmount: delcommafy(item.invoicableAmount),
        discountUnitPriceShow: delcommafy(item.discountUnitPriceShow), //移除需要参与计算的数值千分位分隔符
        discountedUnitPrice: delcommafy(item.discountedUnitPrice), //移除需要参与计算的数值千分位分隔符
        nowInvoiceAmount: delcommafy(item.nowInvoiceAmount), //移除需要参与计算的数值千分位分隔符
        invoicableAmount: delcommafy(item.invoicableAmount), //移除需要参与计算的数值千分位分隔符
        taxAmount: delcommafy(item.taxAmount), //移除需要参与计算的数值千分位分隔符
      }))

      // // 总信息
      let obj = {
        ...orderObj,
        type: 1,
        invoiceCategory:this.queryData.invoiceWay == '1' ? 0 : this.queryData.invoiceWay == '0' ? 1 : '',
         //新增时将this.TableConfig.tableData里每个商品的id置为空 修改时加上id
         xghInvoiceInfoList:this.queryData.invoiceWay == '2' ? [] : this.invoiceId ? e : p

      }
      // console.log('保存：', orderObj)
      var res = {}
      // 修改
      if (this.invoiceId) {
        // 先判断用户是否拥有修改权限
        if (this.buttonsPermissions.XiuGai) {
          res = await putAction('/xghInvoice/xghInvoice/edit', obj)
        } else {
          this.showTips('没有修改权限！')
          return
        }
      } else {
        // 新增
        res = await postAction('/xghInvoice/xghInvoice/add', obj)
      }
      if (res.code === 200) {
        if (this.invoiceId) {
          this.$elMessage.success('修改成功！')
        } else {
          this.$elMessage.success('保存成功！')
        }
        // this.tipsData.resultType = 1
        // this.$refs.successRef.dialogVisible = true
        this.handleData(res.result)
        this.isCreditLimit = false
        // this.toSaveOrExamine()
      } else {
        this.showTips(res.message)
      }
    },
    // 当操作成功后点击了确定按钮之后进行的下一步操作：
    onOptionSuccess() {
      if (this.tipsData.resultType == 1) {
        this.tipsData.resultType == -1
        // 保存成功了
        console.log('操作成功后点击确定按钮了')
        this.toSaveOrExamine()
      } else if (this.tipsData.resultType == 2) {
        this.tipsData.resultType == -1
        // 审核成功了
        console.log('审核成功后点击确定按钮了')
        this.afterExamine()
      }
    },
    // 单据保存后的走向
    toSaveOrExamine() {
      this.onYes('onNewOrder')
      // if (this.isSaveExamine && this.buttonsPermissions.ShenHe) {
      //   // 保存后立即审核,且有审核权限
      //   setTimeout(() => {
      //     this.onToExamine()
      //   }, 1000)
      // } else if (this.isSaveNewOrder && this.buttonsPermissions.LuRu) {
      //   // 如果保存后立即开新单,并且有新增权限
        
      // }
    },
    afterExamine() {
      // 如果审核后立即开新单
      if (this.isExamineNewOrder && this.buttonsPermissions.LuRu) {
        this.onYes('onNewOrder')
      }
    },
    hongchongSure() {
      // 红冲
      this.updateOrder(20)
    },
    // 操作选择
    cancellation() {
      this.tipsData.tipsWords = '确定要作废当前的单据吗？'
      this.tipsData.tipsMark = 'onToVoid'
      this.$refs.reminderRef.dialogVisible = true
    },
    // 导入
    importExcel() {
      this.$refs.daoru.dialogVisible = true
    },
    importData(val) {
      console.log(val)
      if (val.success) {
        this.$elMessage.success(val.message)
        let result = val.result && val.result.records || []
        result.map((item) => {
          item.goodsName = item.goodsId_dictText
          item.isGive = item.isGive == '0' ? true : false //赠品0:是赠品1：不是赠品
          item.unitList = item.goodsManyNorms
          item.unitScale = this.getUnitScale(item.goodsManyNorms, item.unit, 'scale')
          item.baseUnit = this.getUnitScale(item.goodsManyNorms, item.unit, 'id')

          item.xghStorehouseId = item.xghStorehouseId
          item.number = formatFour(item.number)
          item.numberShow = formatNumber(item.number)
          item.notDeliverNumber = formatFour(item.number)
          item.notDeliverNumberShow = formatNumber(item.number)
          item.deliverNumber = formatNumber(0)

          item.discountedUnitPrice = formatFour(item.discountedUnitPrice)
          item.taxAmount = formatFour(item.taxAmount)
          item.allPrice = formatFour(item.allPrice)

          item.invoicedAmount = formatPrice(item.invoicedAmount)
          item.invoicableAmount = formatPrice(item.invoicableAmount)
          item.nowInvoiceAmount = formatPrice(item.nowInvoiceAmount)

          item.discountAmountShow = formatPrice(item.discountAmount)
          item.taxAmountShow = formatPrice(item.taxAmount)

          return item
        })

        if (this.TableConfig.tableData.length == 1 && !this.TableConfig.tableData[0].goodsId) {
          this.TableConfig.tableData = result
        } else {
          this.TableConfig.tableData = this.TableConfig.tableData.concat(result)
        }
        // let result = val.result
        // let orderObj = result.saleOrderPage
        // if (orderObj) {
        //   let list = orderObj.xghSaleOrderInfoList
        //   list && list.forEach((item) => {
        //     item.goodsName = item.goodsId_dictText
        //   })
        // }

        // let payObj = result.collectionPayPage
        // if (payObj) {
        //   let list = payObj.xghCollectionPayInfoList
        //   list && list.forEach((item) => {
        //     item.bankName = item.bankId_dictText
        //   })
        // }

        // this.handleData(result)
      } else {
        this.$elMessage.error(val.message)
      }
    },
    getUnitScale(unitList, defaultUnit, key) {
      if (!unitList || !defaultUnit) {
        return '1'
      }
      for (let index = 0; index < unitList.length; index++) {
        const element = unitList[index]
        if (element.unit == defaultUnit) {
          return element[key]
        }
      }
    },
    // 导出
    exportExcel(isTemplate = false) {
      let id = isTemplate ? '' : this.invoiceId
      let queryParam = {
        id:this.invoiceId,
      }
      this.handleExportXlsByStaff(this.pageName, queryParam)
    },
    // 分享
    onShare() { 
      if (!this.invoiceId) {
        this.$elMessage.warning('未保存单据无法分享！')
      } else if (this.buttonsPermissions.FenXiang) {
        // let base = window._CONFIG['domianURL'].replace('api', '').replace('10030', '9047')        
        // let bookId = Vue.ls.get(ACCOUNT_BOOK).id
        // let url = `${base}share?from=xsdd&aid=${bookId}&bid=${this.invoiceId}`
        // window.open(url)
        let params = `invoiceId=${this.invoiceId}&billType=xsdd&orderType=5`
        this.$refs.share.show(params)
      } else {
        this.$elMessage.warning('没有分享权限！')
      }
    },
    onShareResult() {
      if (!this.invoiceId) {
        this.$elMessage.warning('未保存单据无法查看！')
      } else if (this.buttonsPermissions.FenXiang) {
        this.$refs.share.showResult(this.invoiceId, this.queryData.xghCompanyId_dictText)
      } else {
        this.$elMessage.warning('没有分享权限无法查看！')
      }
    },
    getHaveChange() {
      //获取源数据，将订单状态置成新单状态
      let source = JSON.parse(JSON.stringify(this.$options.data().queryData))
      // this.ckOptions.forEach(item =>{
      //   if (item.isDefault == 1) {
      //     source.xghStorehouseId = item.id
      //   }
      // })
      // source.sysUserId = this.$lcStorage.get('xghUser').id
      // // 获取现有数据，移除自动添加的值
      let current = JSON.parse(JSON.stringify(this.queryData))
      current.sysUserId = ''
      current.invoiceTime = ''
      delete current.createOrderDate
      delete current.createUserName
      // // current.xghStorehouseId = ''
      // // 判断当前数据是否和源数据相同，相同表示未做修改
      let sourceStr = JSON.stringify(source)
      let currentStr = JSON.stringify(current)
      console.log("sourceStr",sourceStr);
      console.log("currentStr",currentStr);
      return sourceStr != currentStr
      // return false
    },
    // 上一条
    onUpper() {
      if (this.orderStatus == 66 && this.getHaveChange()) {
        this.tipsData.tipsWords = '当前单据还未保存，</br>是否继续？'
        this.tipsData.tipsMark = 'onUpper'
        this.$refs.reminderRef.dialogVisible = true
      } else {
        this.switchoverBill(1)
      }
    },
    // 下一条
    onLower() {
      if (this.orderStatus == 66 && this.getHaveChange()) {
        this.tipsData.tipsWords = '当前单据还未保存，</br>是否继续？'
        this.tipsData.tipsMark = 'onLower'
        this.$refs.reminderRef.dialogVisible = true
      } else {
        this.switchoverBill(2)
      }
    },
    switchoverBill(flag) {
      if (this.orderFlag === 0) {
        this.orderFlag = flag
      }
      if (flag === 1) {
        if (
          this.pageTotal === 0 ||
          (this.orderFlag === 1 && this.pageNo === this.pageTotal) ||
          (this.orderFlag === 2 && this.pageNo === 1)
        ) {
          this.$elMessage.warning('已经是第一条了')
          return
        }
        let value = this.orderFlag === 1 ? 1 : -1
        this.pageNo += value
        this.upperLoading = true
        this.getOrderData('0')
      } else if (flag === 2) {
        if (
          this.pageTotal === 0 ||
          (this.orderFlag === 1 && this.pageNo === 1) ||
          (this.orderFlag === 2 && this.pageNo === this.pageTotal)
        ) {
          this.$elMessage.warning('已经是最后一条了')
          return
        }
        let value = this.orderFlag === 1 ? -1 : 1
        this.pageNo += value
        this.lowerLoading = true
        this.getOrderData('1')
      }
    },
   
    // 提醒弹框取消后操作
    onCancel(mark) {
      if (mark == 'onChangeCk') {
        // 改变仓库
        this.getXghStorehouseIdById(true)
      }
    },
    // 提醒弹框确认后操作
    onYes(mark) {
      // 订单状态0.待审核5.审核通过10.作废15.反审20.红冲25.终止30.完成
      if (mark == 'onNewOrder') {
        this.orderStatus = 0
        this.onNewOrder()
      } else if (mark == 'onUpper') {
        // 上一单
        this.switchoverBill(1)
      } else if (mark == 'onLower') {
        // 下一单
        this.switchoverBill(2)
      }else if (mark == 'Automatic') {
        // 自动分配
        this.autoAssign()
      } else if (mark == 'onChangeCk') {
        // 改变仓库
        // 根据出货仓库选择商品里的仓库
        this.getXghStorehouseIdById(false)
      } else if (mark == 'onToExamine') {
        // 审核
        this.examineLoading = true
        this.updateOrder(5)
      } else if (mark == 'onToVoid') {
        // 作废
        this.updateOrder(10)
      } else if (mark == 'onToHongC') {
        // 红冲
        this.updateOrder(20)
      } else if (mark == 'onToStop') {
        // 终止
        // this.updateOrder(25)
        this.stopOrder(2)
      } else if (mark == 'onToFinish') {
        // 完成
        this.stopOrder(1)
      } else if (mark == 'onCopy') {
        // 复制单据
        if (this.orderStatus != 66) {
          this.orderStatus = 66
          this.queryData.id = ''
          this.TableConfig.tableData.forEach((item) => {
            item.id = ''
            item.ignore = false
            item.compulsory = '0'
            item.callDocumentId = undefined
            item.callDocumentType = undefined
          })
          this.paymentEcho.id = ''
          this.paymentEcho.xghCollectionPayInfoList.forEach((item) => {
            item.id = ''
          })
        }
        this.invoiceId = ''
        this.logData.orderId = -1
        this.queryData.orderIndex = ''
        this.queryData.orderState_dictText = ''
        this.queryData.orderNumber = ''
        // this.queryData.orderTime = this.$formatDateTime()
        // this.queryData.createOrderDate = this.$formatDateTime()
        this.queryData.createUserName = this.$lcStorage.get('xghUser').realname
        this.queryData.performState = 0
        this.$refs.simplePrompt.show({
          index: 0,
          text: '单据复制成功',
        })
      } else if (mark == 'onUnCheck') {
        this.checkReVerifyPermission()
      }
    },
    // 销售订单更新接口
    updateOrder(state) {
      if(state == 10){
        
        getAction('/xghInvoice/xghInvoice/invoiceCancel', {
        invoiceId: this.invoiceId,
      }).then((res) => {
        if (res.code === 200) {
          this.invoiceStatus = 1
          this.orderStatus = state
          this.queryData.orderState = state
          this.queryData.orderState_dictText = this.getOrderStatusText(state)
          this.$refs.simplePrompt.show({
            index: 0,
            text: this.getMessageByChangeOrderStatus(state),
          })
        } else if (res.code === 500) {
          this.showTips(res.message)
        }
      }).finally(() => {
        this.examineLoading = false
      })
      }
      // getAction('/xghSaleOrder/xghSaleOrder/changeStatus', {
      //   id: this.invoiceId,
      //   code: state,
      // }).then((res) => {
      //   if (res.code === 200) {
      //     this.orderStatus = state
      //     this.queryData.orderState = state
      //     this.queryData.orderState_dictText = this.getOrderStatusText(state)
      //     this.$refs.simplePrompt.show({
      //       index: 0,
      //       text: this.getMessageByChangeOrderStatus(state),
      //     })
      //     if (state == 5) {
      //       this.afterExamine()
      //     }
      //   } else if (res.code === 500) {
      //     this.showTips(res.message)
      //   }
      // }).finally(() => {
      //   this.examineLoading = false
      // })
    },
    stopOrder(state) {
      getAction('/xghSaleOrder/xghSaleOrder/stopOrder', {
        id: this.invoiceId,
        code: state,
      }).then((res) => {
        if (res.code === 200) {
          this.queryData.performState = state
          if (this.saveData) {
            this.saveData.performState = state
          }
          this.$refs.simplePrompt.show({
            index: 0,
            text: this.getMessageByChangeOrderStatus(state),
          })
          this.handleOperationData()
        } else if (res.code === 500) {
          this.showTips(res.message)
        }
      })
    },
    getOrderStatusText(os) {
      let object = {
        0: '待审核',
        5: '已审核',
        10: '已作废',
        15: '待审核',
        20: '已红冲',
        25: '已终止',
        30: '已完成',
      }
      return object[os + '']
    },
    getMessageByChangeOrderStatus(os) {
      let object = {
        5: '单据审核成功',
        10: '单据作废成功',
        15: '单据反审成功',
        20: '单据红冲成功',
        2: '单据终止成功', //终止和完成使用执行状态
        1: '单据已完成',
      }
      return object[os + '']
    },

    /**
     * 触发单据折扣方法
     */
    onChangeDiscount() {
      if (this.queryData.orderRebate <= 0 || this.queryData.orderRebate > 100) {
        this.queryData.orderRebate = 100
      }
      this.TableConfig.tableData.forEach((item, index) => {
        item.discountRate = this.queryData.orderRebate
      })
      this.$refs.newTableRef.updatePrice()
    },
    // 整单优惠后合计列总金额
    onChangeOrderDiscountPrice() {
      this.queryData.orderDiscountPrice = formatMoney(this.queryData.orderDiscountPrice)
      // 单据金额 = 合计列总金额 - 整单优惠
      this.queryData.purchaseOrderPrice = formatMoney(accSub(delcommafy(this.queryData.orderAllPrice), delcommafy(this.queryData.orderDiscountPrice)))
      // 本次欠款 = 单据金额 - 预收定金
      this.queryData.arrearsPrice = formatMoney(accSub(delcommafy(this.queryData.purchaseOrderPrice), delcommafy(this.queryData.depositPrice)))
    },
    // 预付定金值改变
    onChangeDepositPrice(val) {
      this.clearPaymentData()
      let nIt = {
        companyId: this.queryData.xghCompanyId,
        companyType: 2, //单位类型1:快递收付 2;往来单位收付3：银行账户id
        isBegin: 1, //是否期初0：是期初 1：不是
        payType: 1, //收付类型1:收款2：付款
        price: val,
        xghAccountBookId: this.accountBookId,
      }
      // 如果当前修改了预付定金的值
      if (val) {
        let haveDetault = false

        for (let i = 0; i < this.paymentData.length; i++) {
          // 则判断支付账户中哪个是默认账户
          if (this.paymentData[i].isDefault) {
            haveDetault = true
            this.queryData.bankName = this.paymentData[i].bankName // + ' ' + this.paymentData[i].paymentAmount
            nIt.bankId = this.paymentData[i].id
            nIt.bankName = this.paymentData[i].bankName
          }
        }
        if (!haveDetault && this.paymentData.length) {
          this.paymentData[0].price = -val
          this.queryData.bankName = this.paymentData[0].bankName
          nIt.bankId = this.paymentData[0].id
          nIt.bankName = this.paymentData[0].bankName
        }
      }

      this.queryData.depositPrice = formatMoney(val)
      this.paymentEcho.xghCollectionPayInfoList = [nIt]
      // 本次欠款 = 单据金额 - 预收定金
      this.queryData.arrearsPrice = formatMoney(accSub(delcommafy(this.queryData.purchaseOrderPrice), delcommafy(this.queryData.depositPrice)))
    },
    // 单位改变触发
    onHandleUnit(val, i, transmit) {
      let sc = this.TableConfig.tableData[i].unitScale
      let sc1 = this.getUnitScale(val.unitList, val.unit, 'scale')
      this.TableConfig.tableData[i].unitScale = sc1
      this.TableConfig.tableData[i].baseUnit = this.getUnitScale(val.unitList, val.unit, 'id')
      if (sc && sc > sc1) {
        this.TableConfig.tableData[i].costPrice = this.TableConfig.tableData[i].costPrice / sc
      }else {
        this.TableConfig.tableData[i].costPrice = accMul(this.TableConfig.tableData[i].costPrice, sc1)
      }
      // 设置价格的默认值
      this.$refs.newTableRef.focusPrice('', i, this.TableConfig.tableData[i], transmit)
    },
    // 修改附记
    async updatePostScript() {
      let orderStateNum = Number(this.orderStatus)
      if (orderStateNum >= 5 && orderStateNum < 66) {
        const res = await getAction('/xghSaleOrder/xghSaleOrder/addPostScript', {
          orderId: this.invoiceId,
          postscript: this.queryData.postscript
        })
        if (res.code == 200) {
          this.$elMessage.success("附记修改成功！")
        } else if (res.code === 500) {
          this.$elMessage.error(res.message)
        }
      }
    },
    /**
     * 父组件处理子组件获取到的商品信息数据字段名不统一问题
     * @param tableData 子组件中表格的数据
     * @param index 当前选中this.TableConfig.tableData的索引
     * @param index 从商品表中选中的商品数据
     */
    onHandleSpData(tableData, index, val) {
      // 根据入货仓库选择商品里的仓库
      for (const key in tableData[index]) {
        this.TableConfig.tableData[index].goodsNumber = val.goodsNumber
        this.TableConfig.tableData[index].goodsCode = val.barCode
        this.TableConfig.tableData[index].goodsId = val.id
        this.TableConfig.tableData[index].goodsName = val.goodsName
        this.TableConfig.tableData[index].norms = val.specs
        this.TableConfig.tableData[index].unit = val.defaultUnit
        this.TableConfig.tableData[index].unitList = val.goodsManyNorms
        this.TableConfig.tableData[index].number = formatFour(val.number)
        this.TableConfig.tableData[index].numberShow = formatNumber(val.number)
        this.TableConfig.tableData[index].deliverNumber = formatNumber(0)
        this.TableConfig.tableData[index].notDeliverNumber = formatFour(val.number)
        this.TableConfig.tableData[index].notDeliverNumberShow = formatNumber(val.number)
        this.TableConfig.tableData[index].isGive = false
        this.TableConfig.tableData[index].remark = val.goodsRemark
        this.TableConfig.tableData[index].discountedUnitPrice = formatFour(val.discountedUnitPrice)
        this.TableConfig.tableData[index].taxAmount = formatFour(val.taxAmount)

        this.TableConfig.tableData[index].invoicedAmount = formatPrice(val.discountedUnitPrice)
        this.TableConfig.tableData[index].invoicableAmount = formatPrice(val.discountedUnitPrice)
        this.TableConfig.tableData[index].nowInvoiceAmount = formatPrice(val.discountedUnitPrice)
        this.TableConfig.tableData[index].discountAmountShow = formatPrice(val.discountAmount)
        this.TableConfig.tableData[index].taxAmountShow = formatPrice(val.taxAmount)
        this.TableConfig.tableData[index].ignore = false
        this.TableConfig.tableData[index].compulsory = '0'
        this.TableConfig.tableData[index].costPrice = val.costPrice
        this.TableConfig.tableData[index].taxRate = this.taxRate

        this.TableConfig.tableData[index].extendField1 = val.extendField1
        this.TableConfig.tableData[index].extendField2 = val.extendField2
        this.TableConfig.tableData[index].extendField3 = val.extendField3
        this.TableConfig.tableData[index].extendField4 = val.extendField4
        this.TableConfig.tableData[index].extendField5 = val.extendField5
        this.TableConfig.tableData[index].formulaList = val.formulaList

      }

      //获取默认单位的换算比例
      let temp = {
        ...val,
        unitList: val.goodsManyNorms,
        unit: val.defaultUnit,
      }
      this.onHandleUnit(temp, index, false)
    },
    /**
     * 获取合计列总金额
     * @param value 合计列总金额值
     */
    onHandleAllPrice(value) {
      // console.log('计算总金额');
      let diff = delcommafy(value) - delcommafy(this.queryData.orderDiscountPrice)
      // 单据金额 = 合计列总金额 - 整单优惠
      this.queryData.purchaseOrderPrice = formatMoney(diff)
      // 本次欠款 = 单据金额 - 预收定金
      this.queryData.arrearsPrice = formatMoney(accSub(diff, delcommafy(this.queryData.depositPrice)))
      this.queryData.orderAllPrice = formatMoney(value)
    },
    // 清空多账户付款账户的记录数据
    clearPaymentData() {
      this.paymentEcho.xghCollectionPayInfoList = []
    },
    /**
     * 获取当前单据数据
     */
    getOrderData(type) {
      // 清空物流付款账户信息
      // this.clearPaymentData()
      let data = {
        // ...this.queryData,
        type: 1,
        orderFlag: this.orderFlag,
        pageSize: 1,
        pageNo: this.pageNo,
        invoiceId: this.invoiceId || ''
      }
      getAction('/xghInvoice/xghInvoice/preOrNextOrder', data).then(
        (res) => {
          this.lowerLoading = false
          this.upperLoading = false

          if (res.code === 200) {
            this.pageTotal = res.result.total || 1
            this.pageNo = res.result.current
            let list = res.result.records || []
            if (list.length) {
              // 处理请求到的数据
              this.handleData(list[0])
              // 获取当前单据的扩展字段，赋值给组件
              // this.$nextTick(() => {
              //   // console.log(this.$refs.extendedFieldsRef,'组件---')
              //   this.$refs.extendedFieldsRef.updateTableData(list[0].extendFields)
              // })
            } else {
              if (type == 0) {
                this.$elMessage.warning('已经是第一条了')
              } else {
                this.$elMessage.warning('已经是最后一条了')
              }
            }
          } else if (res.code === 500) {
            this.showTips(res.message)
          }
        },
        (error) => {
          this.lowerLoading = false
          this.upperLoading = false
        }
      )
    },
    
    handleFilterInvoiceWay(e) {
      if (this.activeKpOptions.length === 0) {
        this.activeKpOptions = Object.assign([], this.kpOptions);
      }
      if (e) {
        this.kpOptions = this.activeKpOptions.filter(item => {
          return item.label.indexOf(e) > -1;
        });
      } else {
        this.kpOptions = Object.assign([], this.activeKpOptions);
      }
    },
    // 处理请求到的数据
    handleData(res) {

      // let orderObj = res.saleOrderPage //订单信息
      // let payObj = res.collectionPayPage || { xghCollectionPayInfoList: [] } //支付信息

      this.invoiceId = res.id
      this.invoiceStatus = res.invoiceStatus
      if (res.invoiceStatus == 1) {
        this.orderStatus = 10
      } else {
        this.orderStatus = 2
      }
      // this.logData.orderId = orderObj.id

      // this.queryData = {
      //   ...res,
      // }

      this.queryData ={
        type: 1,
        id: res.id, //id
        xghCompanyId: res.xghCompanyId, //客户id
        sysUserId: res.sysUserId, //经手人id
        sysUserId_dictText: res.sysUserId_dictText, //经手人
        departId: res.departId, //部门id
        departId_dictText: res.departId_dictText, //部门
        invoiceTime: res.invoiceTime, //开票日期
        invoiceNumber: res.invoiceNumber, // 发票号码
        invoiceType: res.invoiceType, // 发票类型
        invoiceType_dictText: res.invoiceType_dictText, // 发票类型
        invoicePrice: res.invoicePrice, // 开票金额
        invoiceWay: res.invoiceWay, //开票方式
        invoiceWay_dictText: res.invoiceWay_dictText, // 开票方式
        price: formatMoney(res.price),  // 不含税金额
        taxAmount: formatMoney(res.taxAmount),     // 税额
        priceTaxTotal: formatMoney(res.priceTaxTotal)  // 价税合计
      }
      
      if (res.xghCompanyId) {
        let h = this.gysOptions.some(item => item.id == res.xghCompanyId)
        if (!h) {
          this.getGysStorage()
        }
      }
     
      this.attachments = (this.queryData.attachment || '').split(',').filter((item) => item)
      // this.queryData.isSupplement = res.isSupplement == '1' ? false : true //是否补单-0：是 1:不是
      const newTableList = res.xghInvoiceInfoList
      newTableList.forEach((item) => {
        // item.isGive = item.isGive == '0' ? true : false //赠品0:是赠品1：不是赠品
        item.number = formatFour(item.number)
        item.numberShow = formatNumber(item.number)
        item.notDeliverNumber = formatFour(item.notDeliverNumber)
        item.notDeliverNumberShow = formatNumber(item.notDeliverNumber)
        item.deliverNumber = formatNumber(item.deliverNumber)

        item.taxAmount = formatFour(item.taxAmount)
        item.allPrice = formatFour(item.allPrice)

        item.discountedUnitPrice = formatPrice(item.discountedUnitPrice)
        item.discountAmount = formatPrice(item.discountAmount)
        item.taxAmount = formatPrice(item.taxAmount)
        item.discountAfterPrice = formatPrice(item.discountAfterPrice)

        item.invoicedAmount = formatPrice(item.invoicedAmount)
        item.invoicableAmount = formatPrice(item.invoicableAmount)
        item.nowInvoiceAmount = formatPrice(item.nowInvoiceAmount)

        item.invoicedOrderAmount = formatPrice(item.invoicedAmount)
        item.invoicableOrderAmount = formatPrice(item.invoicableAmount)

        item.discountAmountShow = formatPrice(item.discountAmount)
        item.taxAmountShow = formatPrice(item.taxAmount)
        item.unitList = item.goodsManyNorms
        item.goodsName = item.goodsName ? item.goodsName : item.goodsId_dictText
        item.compulsory = '0'

        item.allPriceShow = formatMoney(accMul(delcommafy(formatNumber(item.number)), delcommafy(formatPrice(item.taxAmount))))

        item.goodsPrice = item.salePrice
      })

      
      // 增加字段数据，避免不能更新页面
      this.TableConfig.tableData = JSON.parse(JSON.stringify(newTableList))
      for (let index = 0; index < this.TableConfig.tableData.length; index++) {
        const element = this.TableConfig.tableData[index];
        if (element.formulaId) {
          this.$refs.newTableRef.formulaChange(element.formulaId, element, index) 
        } 
      }

      // this.paymentEcho = res
      // let list = res.xghCollectionPayInfoList
      // let names = []
      // for (let index = 0; index < list.length; index++) {
      //   const element = list[index]
      //   if (element.price != 0) {
      //     names.push(element.bankName)
      //     element.price = Math.abs(element.price)
      //   }
      // }
      // this.queryData.bankName = names.join(';')

      if (this.queryData.invoiceWay == '1' || this.queryData.invoiceWay == '2') {
        this.TableConfig.columnData = this.byBillcolumnData
      }else{
        this.TableConfig.columnData = this.byCommoditycolumnData
      }
      
      this.printData = {
        ...this.queryData,
        ...getPrintCompanyInfo(this.gysOptions, this.queryData.xghCompanyId),
        printExclusive: this.TableConfig.tableData
      }

      this.saveData = JSON.parse(JSON.stringify({
        ...this.queryData,
        ...this.TableConfig.tableData,
      }))
      this.saveData.purchaseOrderPrice = 0
    },

    /**
     * 选择仓库数据
     */
    onChangeCk(val) {
      let result = false
      for (let index = 0; index < this.TableConfig.tableData.length; index++) {
        const element = this.TableConfig.tableData[index]
        if (element.goodsId) {
          result = true
          break
        }
      }
      console.log(result)
      if (result) {
        this.tipsData.tipsWords = '是否更新单据明细中的仓库？'
        this.tipsData.tipsMark = 'onChangeCk'
        this.$refs.reminderRef.dialogVisible = true
      } else if (this.TableConfig.tableData.length == 1 && !this.TableConfig.tableData[0].goodsId) {
        this.TableConfig.tableData[0].xghStorehouseId = val
      }
      console.log(this.TableConfig.tableData)
    },
    // 根据入货仓库选择商品里的仓库
    // force是否强制更新，true 用户选择不更新单据详情时 为空的强制赋值，false 选择更新单据 全部覆盖
    getXghStorehouseIdById(force) {
      this.TableConfig.tableData.forEach((item) => {
        if (force) {
          if (!item.xghStorehouseId) {
            item.xghStorehouseId = this.queryData.xghStorehouseId
          }
        } else {
          item.xghStorehouseId = this.queryData.xghStorehouseId
        }
        console.log(item)
      })
    },

    // 打开选择商品弹出框 关闭商品历史记录弹出表
    onShowCommodity() {
      this.$refs.popoverRef[0].doClose()
      this.$refs.commodityRef.dialogVisible = true
    },
    // 打开新增经手人的弹框
    onShowStaffAdd() {
      this.$refs.staffAddRef.dialogVisible = true
    },
    // 获取新增经手人数据
    onAddStaff(val) {
      postAction('/dept/xghAccountBookDept/addAccountBookUser', val).then((res) => {
        if (res.code === 200) {
          this.$elMessage.success(res.message)
          this.$refs.staffAddRef.dialogVisible = false
          this.getStaffData()
        } else {
          this.$elMessage.error(res.message)
        }
      })
    },
    // 关闭新增经手人时清空
    onCloseAddStaff() {
      this.newStaffData = this.$options.data().newStaffData
    },
    // 打开操作日志弹框
    onShowLog() {
      this.$refs.operationLogRef.getData(this.logData)
      this.logTitle = '单据操作日志'
      this.$refs.operationLogRef.dialogVisible = true
    },
    // 选择供应商时触发
    onClickCompany(val) {
      this.paymentEcho.companyId = val
    },
    // 打开新增供应商弹出框
    onShowSupplierAdd() {
      this.newData = {
        id: '',
        companyName: '',
        companyUserName: '',
        xghCompanyNatureId: '',
        xghCompanyNature: '',
        companyPhone: '',
        companyPinyinCode: '',
        companyLandline: '',
        xghCompanyTypeId: '', //单位类别
        xghCompanyType: '',
        business: '',
        provinceName: '', //省
        provinceCode: '',
        cityName: '', //市
        cityCode: '',
        countyName: '', //区县
        countyCode: '',
        address: '',
        setPrice: '',
        setDiscountPrice: '',
        companyInvoiceStatus: true,
        depositBank: '',
        bankName: '',
        bakCard: '',
        taxNumber: '',
        invoiceAddress: '',
        bankPhone: '',
        companyRAndPStatus: true,
        beginReceivable: 0,
        beginPayable: 0,
        totalReceivable: 0,
        totalPayable: 0,
        receivableQuota: '',
        payableQuota: '',
        receivableTime: '',
        payableTime: '',
        companyRemark: '',
      }
      this.$refs.supplierAddRef.dialogVisible = true
    },
    onShowSupplierEdit() {
      this.newData = this.gysOptions.find(item => item.id == this.queryData.xghCompanyId)
      if(!this.newData){
        this.$elMessage.warning('请先选择客户')
        return
      } 
      // 0:是 1:否
      this.newData.companyInvoiceStatus = this.newData.companyInvoiceStatus == '0' ? true : false
      this.newData.companyRAndPStatus = this.newData.companyRAndPStatus == '0' ? true : false
      this.$refs.supplierAddRef.dialogVisible = true
    },
    // 新增供应商数据
    onAddSupplier(res) {
      this.getGysStorage()
    },
    // 打开选择供应商弹出框
    onShowSupplier() {
      this.$refs.supplierRef.dialogVisible = true
    },
    // 当前选择供应商数据
    onSelectSupplier(val) {
      this.queryData.xghCompanyId = val.id
    },
    
    onCloseAddSupplier() {
      // this.newData = this.$options.data().newData
    },
    // 新增数据中表格内输入框聚焦时选中
    focusinSelect() {
      event.target.select()
    },
    // 历史记录数据去重并只展示三个数据方法
    selectDataHas(arr) {
      let map = new Map()
      for (const item of arr) {
        if (!map.has(item.id)) {
          map.set(item.id, item)
        }
      }
      let newArr = [...map.values()]
      return newArr.slice(0, 3)
    },
    showTips(msg) {
      this.$elMessage({
        showClose: true,
        message: msg || '',
        type: 'error',
        iconClass: 'el-icon-warning-outline',
        duration: 3000,
      })
    },
    // 搜索
    handleFilterMethod(value, label) {
      if (label == 'companyName') {
        this.gysOptions = this.filterMethod(this.gysOptions, value, label)
      } else if (label == 'storehouseName') {
        this.ckOptions = this.filterMethod(this.ckOptions, value, label)
      } else if (label == 'realname') {
        this.jsrOptions = this.filterMethod(this.jsrOptions, value, label)
      }
    },
    // 选择当前类别
    onSelectTree (val) {
      if (this.toTreeData.module.name == 'deptName') {
        // this.newData.deptName = val.companyTypeName
        this.newData.departId = val.id
      } else if (this.toTreeData.module.name == 'companyTypeName') {
        // this.newData.companyTypeName = val.companyTypeName
        this.newData.xghCompanyTypeId = val.id
      }

      this.$forceUpdate()
    },
  },
}
</script>

<style lang="scss" scoped>
::v-deep .custom_line {
  .el-input {
        width: 150px;
        height: 30px;
        box-sizing: border-box;
        margin-right: 10px;
        input{
          width: 100%;
          height: 100%;
        }
      }
}
 .chaoZuoBtn {
          width: 80px;
          height: 30px;
          display: flex;
          align-items: center;
          justify-content: center;
          // font-size: 0.225014rem;
          font-size: 12px;
          // color: #666;
          // background: #fff;
        }
.custom_more{
  right: 33px;
  // right: 21px;
}
.custom_select_head{
  display: flex; 
  align-items: center;
}
.basic_info {
  width: 100%;
  height: 100%;
  background: #f0f2f5;
  box-sizing: border-box;
  padding: 0 10px 10px 10px;
  display: flex;
  flex-direction: column;
}

.info_operation_btn {
  width: 100%;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: PingFang SC;
  font-size: 12px;

  ::v-deep .el-button {
    // width: 70px;
    height: 30px;
    text-align: center;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    border-radius: 0.093756rem;
    border: none;
    margin-right: 0.1rem;
    margin-left: 0;
    padding: 9px 0.2rem;
  }

  // .el-button--default {
  //   color: #666;
  // }

  ::v-deep .el-select {
    height: 30px;
    box-sizing: border-box;
    margin-right: 10px;

    .el-input {
      height: 100%;

      .el-input__inner {
        width: 70px;
        height: 100%;
        border: none;
        font-size: 12px;
      }

      .el-input__suffix {
        height: 100%;
        display: flex;
        align-items: center;
      }

      .el-textarea {
        height: 100%;
        width: 30px;
      }
    }
  }

  ::v-deep .el-checkbox {
    display: flex;
    align-items: center;
    margin-left: 10px;

    .el-checkbox__input {
      height: 19px;
      display: flex;
      align-items: center;
    }

    .el-checkbox__label {
      font-size: 12px;
      padding-left: 5px;
      color: #666;
    }

    .is-checked {
      .el-checkbox__inner {
        background: #1a93fa;
        border-color: #1a93fa;
      }
    }
  }

  .arrow_btn {
    width: 30px;
    height: 30px;
    background: #ffffff;
    padding: 0;
    margin-right: 0;
  }

  p {
    font-size: 12px;
    color: #666;
    margin-right: 0.25rem;
  }

  .search_order {
    display: flex;
    align-items: center;
    margin-left: 10px;

    p {
      margin-right: 0;
    }
  }

  .btn_left {
    height: 100%;
    display: flex;
    justify-content: flex-start;
    align-items: center;
  }

  .btn_right {
    height: 100%;
    display: flex;
    justify-content: flex-end;
    align-items: center;
  }
}

.info_content_div {
  width: 100%;
  height: calc(100% - 50px);
  background: #fff;
  box-sizing: border-box;
  padding: 0 10px;
  display: flex;

  .div_table {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;

    .div_screen {
      width: 100%;
      // heig ht: 50px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .custom_left{
        flex-wrap: wrap;
      }
      ::v-deep .el-input {
        width: 150px;
        height: 30px;
        box-sizing: border-box;
        margin-right: 10px;
        input{
        height: 100%;
        }
      }

      ::v-deep .el-select {
        height: 30px;
        box-sizing: border-box;
        margin-right: 10px;

        .el-input {
          height: 100%;

          .el-input__inner {
            height: 100%;
            font-size: 12px;
          }

          .el-input__suffix {
            height: 100%;
            display: flex;
            align-items: center;
          }

          .el-textarea {
            height: 100%;
            width: 30px;
          }
        }
      }

      ::v-deep .el-date-editor {
        width: 120px;
        height: 30px;

        .el-input__inner {
          width: 100%;
          height: 30px;
          padding: 0 0.187512rem;
          font-size: 12px;
          color: #666;
        }

        .el-input__prefix {
          left: unset;
          right: 5px !important;

          .el-input__icon {
            line-height: 30px;
            font-size: 16px;
          }
        }

        .el-input__suffix {
          display: none;
        }
      }

      .screen_right {
        width: 30px;
        height: 30px;
        box-sizing: border-box;
        display: flex;
        justify-content: center;
        align-items: center;
        box-sizing: border-box;

        .set_up {
          line-height: 20px;
          font-size: 20px;
          color: rgb(153, 153, 153);
        }
      }
    }

    .table_content {
      flex: 1;
      margin-top: 10px;
      box-sizing: border-box;
      overflow: auto;

      >div {
        width: 100%;
        height: 100%;
        border: 1px solid #e3e3e3;
      }
    }

    .table_calculation {
      width: 100%;
      height: 170px;
      box-sizing: border-box;
      padding: 10px 0;
      display: flex;
      justify-content: space-between;
      overflow: hidden;
      overflow-x: auto;

      .table_item {
        height: 30px;
        margin-bottom: 10px;
        display: flex;
        align-items: center;

        ::v-deep .el-button {
          width: 80px;
          height: 30px;
          display: flex;
          align-items: center;
          justify-content: center;
          // font-size: 0.225014rem;
          font-size: 12px;
          color: #666;
          background: #fff;
        }

        .el-button--primary {
          color: #1b94fb;
          border-color: #1b94fb;
        }

        >p,
        span {
          margin: 0;
          // font-size: 0.225014rem;
          font-size: 12px;
          color: #666;
        }

        >p {
          width: 50px;
          text-align: justify;
          text-justify: distribute-all-lines;
          /*ie6-8*/
          text-align-last: justify;
          /* ie9*/
          -moz-text-align-last: justify;
          /*ff*/
          -webkit-text-align-last: justify;
          /*chrome 20+*/
        }

        > ::v-deep .el-input {
          width: 312px;
          height: 30px;

          .el-input__inner {
            height: 100%;
            padding: 0 0.150009rem;
            // font-size: 0.225014rem;
            font-size: 12px;
            color: #666;
          }
        }

        ::v-deep .el-select {
          // width: 1.875117rem;
          width: 1rem;
          // height: 0.562535rem;
          height: 30px;
          box-sizing: border-box;
          border-radius: 4px;

          .el-input {
            .el-input__inner {
              // height: 0.562535rem;
              height: 30px;
              border-color: #e3e3e3;
              // font-size: 0.225014rem;
              font-size: 12px;
              padding-left: 0.150009rem;
            }

            .el-input__suffix {
              // height: 0.562535rem;
              height: 30px;
              display: flex;
              align-items: center;
            }
          }
        }

        .payDate_input {
          width: 1.875117rem;
          // height: 0.562535rem;
          height: 30px;
          position: relative;
          display: flex;
          align-items: center;

          ::v-deep .el-input {
            width: 100%;
            // height: 0.562535rem;
            height: 30px;

            .el-input__inner {
              height: 100%;
              padding: 0 0.468779rem 0 0.187512rem;
              // font-size: 0.225014rem;
              font-size: 12px;
              color: #666;
              text-align: left;
              text-align-last: left;
            }
          }

          i {
            position: absolute;
            right: 0.12rem;
            // margin-right: 0.187512rem;
            color: #bfbfbf;
            font-size: 12px;
            cursor: pointer;
          }
        }

        .span_style {
          font-size: 24px;
          font-family: PingFang SC;
          font-weight: 600;
          color: #ff6c00;
        }

        &:last-child {
          margin-bottom: 0;
        }
      }
    }
  }
}

.scan_div {
  width: 100%;
  position: relative;
}

.scan_popover {
  position: fixed;
  top: 3.000188rem;
  left: 6rem;
  z-index: 1;
  padding: 0.112507rem;
  background: #fff;
  border: 1px solid #eee;
  display: flex;
  align-items: center;
  box-shadow: 1px 1px 5px 2px rgba(0, 0, 0, 0.2);
  display: none;

  .close_scan {
    position: absolute;
    top: -0.187512rem;
    left: 4.950309rem;
    font-size: 0.337521rem;
    cursor: pointer;
    color: #666;
  }

  ::v-deep .el-input {
    width: 3.375211rem;
    // height: 0.562535rem;
    height: 0.55rem;

    .el-input__inner {
      width: 100%;
      height: 100%;
      border-color: #1893fc;
      border-radius: 0;
      padding: 0 0.112507rem;
    }
  }

  p {
    width: 1.500094rem;
    // height: 0.562535rem;
    height: 0.55rem;
    background: #1893fc;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    // font-size: 0.225014rem;
    font-size: 12px;
    margin: 0;
  }
}

.disabled_button {
  background: #cbced3 !important;
  color: #666 !important;
}

.table_popover {
  .el-table {
    border: 1px solid #e3e3e3;
    box-sizing: border-box;

    th,
    td {
      padding: 0;
      color: #666;
      box-sizing: border-box;
      border-right: 1px solid #e3e3e3;

      .cell {
        // height: 0.562535rem;
        height: 0.55rem;
        display: flex;
        align-items: center;
        // font-size: 0.225014rem;
        font-size: 12px;
      }

      &:first-child {
        .cell {
          justify-content: center;
        }
      }

      &:last-child {
        border-right: none;
      }
    }

    th {
      .cell {
        background: #ededed;
        justify-content: center;
      }
    }

    .el-table__body tr:hover>td {
      background: #e3f6ff;
    }

    .el-table__footer-wrapper {
      td {
        background: #f4f4f4;
        border: none;
      }
    }

    //滚动条的宽度
    ::-webkit-scrollbar {
      width: 10px;
      height: 10px;
      background-color: #e5e5e5;
    }

    //滚动条的滑块
    ::-webkit-scrollbar-thumb {
      background-color: #c9c9c9;
    }
  }

  .new_table_style {
    // height: 0.562535rem;
    height: 0.55rem;
    border: 1px solid #e3e3e3;
    border-top: none;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ededed;
  }
}

.bill_mask_view_script {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 40px;
  z-index: 10;
}
.act_view {
  width: 220px;
  padding-left: 20px;
}
.uploader {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  position: relative;
  overflow: hidden;
  width: 52px;
  height: 52px;
  margin: 0 10px 6px 0;
}
.attachment_view {
  border: 1px dashed white;
  width: 52px;
  height: 52px;
  background-color: #f6f6f6;
  line-height: 40px;
  text-align: center;
  border-radius: 3px;
  margin: 0 10px 6px 0;
}
.attachment_mask {
  z-index: 2;
  position: absolute;
  right: 0;
  top: 0;
  width: 12px;
  height: 12px;
  display: flex;
  align-items: center;
}
.attachment_mask_pre {
  z-index: 1;
  position: absolute;
  display: flex;
  align-items: center;
  pointer-events: none;
  right: 0;
  top: 0;
  left: 0;
  bottom: 0;
  backdrop-filter: blur(1px);
  img{
    position: absolute;
    width: 14px;
    height: 14px;
    transform: translate(-50%, -50%);
    top: 50%;
    left: 50%;
  }
}
.default-button {
  padding: 5px 10px;
  border: #0089ff 1px solid;
  border-radius: 5px;
  color: #0089ff;
  height: max-content;
  margin: 0 10px;
  flex-shrink: 0;
  cursor: pointer;
}
</style>
